1

我正在为 Angular 7 项目使用 jquery scrollify。我已经使用这个命令来安装 jquery-scrollify

npm i jquery-scrollify

然后在 angular.json 中添加它的路径

"node_modules/jquery-scrollify/jquery.scrollify.js",

并在我的第一个组件中使用了这段代码

$.scrollify({
    section : ".sectionCommon",
    sectionName : "section-name",
    interstitialSection : "",
    easing: "easeOutExpo",
    scrollSpeed: 1100,
    offset : 0,
    scrollbars: false,
    standardScrollElements: false,
    setHeights: true,
    overflowScroll: true,
    updateHash: false,
    touchScroll:true,
    before:function() {},
    after:function() {},
    afterResize:function() {},
    afterRender:function() {}
});

并且 scrollify 开始显示其对该组件的影响,但是当它也开始显示其对其他组件的影响时,就会出现问题。页面停止滚动。我在其他组件上尝试了以下代码但不起作用

$.scrollify.disable();

或者

$.scrollify.destroy();

请告诉我在 Angular 7 中添加 jquery scrollify 的正确方法

4

1 回答 1

0

首先在组件中导入并声明jquery

import * as jQuery from 'jquery';
declare var jQuery: any;

和 ngAfterViewInit() 函数使用 jquery scrollify 插件。

  ngAfterViewInit() {
    jQuery.scrollify({
      section : "section",
      sectionName : "section-name",
      interstitialSection : "",
      easing: "easeOutExpo",
      scrollSpeed: 1100,
      offset : 0,
      scrollbars: true,
      standardScrollElements: "",
      setHeights: true,
      overflowScroll: true,
      updateHash: true,
      touchScroll:true,
      before:function() {},
      after:function() {},
      afterResize:function() {},
      afterRender:function() {}
    });
  }
于 2019-10-26T02:49:45.713 回答