Giter Site home page Giter Site logo

Comments (3)

manabuyasuda avatar manabuyasuda commented on May 25, 2024

package.jsonのdependenciesにあるパッケージは以下の方法でインポートする。

import $ from 'jquery';
import picturefill from 'picturefill';

自作ファイルは以下のように相対パスでインポートする(関数の呼び出しは不要)。

import jsAlignHeight from './namespace/js/alignHeight.js';

from website-template.

manabuyasuda avatar manabuyasuda commented on May 25, 2024

import文はどちらが適切か?

import { export } from "module-name";
import "module-name";

jQueryはexport$を指定しないと、そのファイルでjQueryが使えない。
exportは名前空間のような役割になっている?ので、指定したほうが無難?

from website-template.

manabuyasuda avatar manabuyasuda commented on May 25, 2024

jQueryプラグインの修正

import $ from 'jquery';
import 'jquery-match-height';
export default function jsAlignHeight () {
  $('.js-alignHeight').matchHeight();
};
import SmoothScroll from 'smooth-scroll';
export default function jsSmoothScroll () {
  const jsSmoothScroll = new SmoothScroll('.js-smoothScroll', {
    ignore: '.js-smoothScroll-ignore', // Selector for links to ignore (must be a valid CSS selector)
    header: '.js-smoothScroll-header', // Selector for fixed headers (must be a valid CSS selector)
    topOnEmptyHash: true, // Scroll to the top of the page for links with href="#"
    speed: 500, // Integer. How fast to complete the scroll in milliseconds
    clip: true, // If true, adjust scroll distance to prevent abrupt stops near the bottom of the page
    easing: 'easeInOutCubic' // Easing pattern to use
  });
};
import jsAlignHeight from './namespace/js/alignHeight';
import jsSmoothScroll from './namespace/js/smoothScroll';

jsAlignHeight();
jsSmoothScroll();

from website-template.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.