有没有办法以角度使用机车滚动。我在谷歌上没有找到任何关于此的内容。有人曾经在角度使用过机车卷轴吗?
我尝试将它导入到我的 homepage.component.ts 中:
import {Component, HostListener, OnInit} from '@angular/core';
import {AppComponent} from '../app.component';
import LocomotiveScroll from 'locomotive-scroll';
@Component({
selector: 'app-homepage',
templateUrl: './homepage.component.html',
styleUrls: ['./homepage.component.css']
})
export class HomepageComponent implements OnInit {
scroll;
constructor() {
}
@HostListener('window:load')
initLocomotiveScroll() {
this.scroll = new LocomotiveScroll({
el: document.querySelector('[data-scroll-container]'),
smooth: true,
});
}
}
homepage.componenet.html :
<div data-scroll-container style="height: 100%; overflow: scroll">
<div data-scroll-section>
<h1 data-scroll>Hey</h1>
<p data-scroll></p>
</div>
<div data-scroll-section>
<h2 data-scroll data-scroll-speed="1">What's up?</h2>
<p data-scroll data-scroll-speed="2"></p>
</div>
</div>
提前致谢。
杰里米。