Giter Site home page Giter Site logo

ameesme / slimscroller.js Goto Github PK

View Code? Open in Web Editor NEW
135.0 5.0 8.0 38 KB

Smoothly scroll to positions and anchors on your website, under 350 bytes, no dependencies.

Home Page: https://amees.me/files/public/SlimScroller.js/demo.html

License: MIT License

JavaScript 51.14% HTML 48.86%

slimscroller.js's People

Stargazers

Nick Whiu avatar Ketyra Sai avatar Shoora avatar lower avatar Jonathan Shobrook avatar  avatar Daniel Sokil avatar wangerniu avatar Alican Kahramaner avatar RAJESHW avatar BenBen avatar 王浩然 avatar Pan Cao avatar  avatar win avatar SwhGo_oN avatar Dmitrii Bykov avatar Vasyl Pahut avatar Imran Parkar avatar Mario Loncarek avatar Thomas Eckhardt avatar Riccardo Bartoli avatar Alper Ortac avatar Ryan Ogden avatar Jan Karger ツ ☀ avatar Mike Ward avatar Jon B avatar Gordan Ratkovic avatar 陆春 avatar Lucas Pereira avatar Felipe Podestá avatar Vlad Radulescu avatar Rhys Arkins avatar Martinez Andres avatar Bart Vandeputte avatar scott avatar  avatar Barney Scott avatar Charles Beaumont avatar Diederik avatar Torsten Baldes avatar Patrick Sullivan avatar  avatar Gabriel Svennerberg avatar  avatar Gabriel Dumitrescu avatar Fredy Mendez avatar Matt Zimmermann avatar Luiz Bills avatar Rio Purnomo avatar Glenn Jorde avatar Paul Anthony avatar Bernardo Baquero Stand avatar Chee Aun avatar Revoltech avatar Kasper Lewau avatar Nick Dixon avatar  avatar Chavin avatar Tamás Sándor Kovács avatar Brad Dougherty avatar Pete Houston avatar Rothana Choun avatar Febril Cuevas avatar Search A Blue avatar Abdullah Norozi Iranzad avatar vaibhav avatar  avatar Sean O avatar Benjamin Hockley avatar zecmo avatar hyb628 avatar  avatar Kaan Karakaya avatar Sergey Gurinovich avatar BJR Matos avatar Y! avatar Sandeep Gupta avatar ollieSk8 avatar Yankai avatar  avatar Ton Smets avatar Jonny Buchanan avatar Anatoly avatar Ben Forshey avatar H avatar Braunson Yager avatar Buddha Rey avatar Rahul Doshi avatar Conan avatar ImFantuan avatar Luís Rodrigues avatar WenryXu avatar  avatar tanangular avatar Guang avatar Nyanpass avatar Van avatar Daniel Waardal avatar ZenPHP avatar

Watchers

tanangular avatar Mees Boe avatar YY avatar ZenPHP avatar  avatar

slimscroller.js's Issues

Please use closures (So you don't have to create the functions everytime .scroll() is called

Closures
Every time you call slimScroller.scroll() you're recreating the following functions:

var easeInOutCubic = function (time) {
    return (time < 0.5) ? 4 * time * time * time : (time - 1) * (2 * time - 2) * (2 * time - 2) + 1;
};
var position = function (start, end, elapsed, duration) {
    return (elapsed > duration) ? end : start + (end - start) * easeInOutCubic(elapsed / duration);
};

Recreating requestAnimationFrame variable:

var requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame;

Recreating this function as well:

var step = function () {
            var elapsed = Date.now() - clock;
            var finalPosition = position(start, targetPosition, elapsed, duration);
            if(horizontal){window.scroll(finalPosition, 0);}else{window.scroll(0, finalPosition);}

            if (elapsed > duration) {
                if (callback) {
                    callback(window.scrollY);
                }
            } else {
                requestAnimationFrame(step);
            }
        };

also why do you wrap this around try catch:

 try{
            parseSelector = document.querySelector(target);
        }catch(e){}

Last thing don't use console.error(); Line 35

Throw an Error instead:

throw Error('Unknown type as target');

**It seems like you're just learning javascript so instead of doing a pull request I'll let you take care of these issues and I'll help you as you fix this

demo not available

the demo link leads to a page that says, "Cannot GET /files/public/SlimScroller.js/demo.html".

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.