GithubHelp home page GithubHelp logo

gitfr33 / number-swiper Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 7 KB

A rolling number selector for elegant, mobile-friendly, number selection UI. (in vanilla javascript)

CSS 14.55% HTML 15.81% JavaScript 69.64%

number-swiper's People

Contributors

gitfr33 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

number-swiper's Issues

Fixed: Jumpy Scrolling After Reaching End of List

jfrohn at StackOverflow had a solution to the problem I was having while repurposing your number swiper.

I use it with a single column and numbers that go 0-100, 99-1, 0, 1-99, 100-0 just to get the data-value for my use. The problem I would have happens when I reach the end of the list. When I get to the top or bottom, the page jumps down like 1000px. I found out this happens when the .scrollIntoView() method is called. You can change one line in your js file and get a cool new effect and no more problems at all.

Try this out:
if (number.target.classList.contains('last-zero')) { console.log('we reached the end re-center the column'); NS.el.querySelector('#center-' + column).**scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'start' })**; console.log(NS.el.querySelector('#center-' + column)) }

Just change NS.el.querySelector('#center-' + column).scrollIntoView()
to NS.el.querySelector('#center-' + column).scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'start' })

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.