Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not using es6 or babel or require #67

Closed
adamjw3 opened this issue May 24, 2017 · 3 comments
Closed

Not using es6 or babel or require #67

adamjw3 opened this issue May 24, 2017 · 3 comments

Comments

@adamjw3
Copy link

adamjw3 commented May 24, 2017

I'm loading the script in my html

/resources/js/plugins/smooth-scrolling.min.js

In my js file i have

var section = document.querySelector(".js-slider");
var child = document.querySelector(".js-item");

    var smooth = new Smooth({
        preload: false,
        native: false,
        direction: "horizontal",
        section: section,
        divs: child
    });

    smooth.init();

But this doesn't do anything, I can see from you demos and code examples you are using es6. I'm not i'm using old javascript. how do i extend smooth to use the custom.js (as per demos) but not use es6!

i've tried bits like this

var smooth = new Smooth({
preload: false,
native: false,
direction: "horizontal",
section: section,
divs: child,
run: function() {
// do something
}

    });

Thanks

@adamjw3 adamjw3 changed the title Not using es6 Not using es6 or babel or require May 24, 2017
@baptistebriel
Copy link
Owner

Hi there,

Sorry for the late answer! If you're not using ES6 or extending the base class of Smooth you can still use the basics by loading smooth-scrolling.min.js.

See this demo; there's no additional JavaScript classes, only the required code to initialise it.
Passing a run function to the options will do nothing, as it's not listed in the README.

Passing divs in the options using smooth-scrolling.min.js will do not work either because this snippet has been taken from another demo that has other options.

There's a few other ways to extend a function prototype; have a read here on MDN and on Stack Overflow. If you can implement ES6 + babel, I'd recommend it. ES6 has just simpler ways to do the same thing we do in ES5, like extending a function's prototype.

@adamjw3
Copy link
Author

adamjw3 commented Jul 31, 2017

Been looking more at es6 so adding this to my workflow using grunt. Looking at using browserfy with babel transform. What do you use?

I've seen that a lot of people either do one bundle across all pages or attempt to split the bundle into pages. What do you do?

@baptistebriel
Copy link
Owner

Hey @adamjw3, sorry for replying one year later. 😅
You can have a look at the package.json of this repository, I'm using simple npm scripts. Obviously, you'd rather use grunt/gulp or webpack for bigger projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants