gitfr33 / number-swiper Goto Github PK
View Code? Open in Web Editor NEWA rolling number selector for elegant, mobile-friendly, number selection UI. (in vanilla javascript)
A rolling number selector for elegant, mobile-friendly, number selection UI. (in vanilla javascript)
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' })
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.