Scroll Zoom Speed Logic
See original GitHub issueHello, In one of my projects, I had to implement logic to increase zoom speed based on how fast the user is scrolling the mouse wheel. I figured that this might be a useful feature for some, so I decided to post it here. Here’s the core code:
viewer.addHandler("canvas-scroll", function (event) {
//Create var to count number of consecutive scrolls that have taken place within the specified time limit of each other
if (typeof this.scrollNum == 'undefined') {
this.scrollNum = 0;
}
//Create var to store the time of the previous scroll that occurred
if (typeof this.lastScroll == 'undefined') {
this.lastScroll = new Date();
}
this.currentScroll = new Date(); //Time that this scroll occurred at
//If the last scroll was less than 400 ms ago, increase the scroll count
if (this.currentScroll - this.lastScroll < 400) {
this.scrollNum++;
}
//Otherwise, reset the count and zoom speed
else {
this.scrollNum = 0;
viewer.zoomPerScroll = 1.2;
}
//If user has scrolled more than twice consecutively within 400 ms, increase the scroll speed with each consecutive scroll afterwards
if (this.scrollNum > 2) {
//Limit maximum scroll speed to 2.5
if (viewer.zoomPerScroll <= 2.5) {
viewer.zoomPerScroll += 0.2;
}
}
this.lastScroll = this.currentScroll; //Set last scroll to now
});
Currently there are a lot of hard coded values but those could easily be changed to variables.
Enjoy!
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Scroll and zoom in the Tracks area in Logic Pro - Apple Support
In Logic Pro, click and hold the Waveform Zoom button in the Tracks area menu bar, then drag the slider vertically to zoom...
Read more >Changing Mouse Scroll Zoom Behavior - Logic Pro Help
Currently the setting to horizontally "zoom out" and "zoom in" is to hold the "ALT" key while scrolling the THUMB mouse wheel from...
Read more >Zoom Super Fast in Logic Pro X - Professional Composers
You simply hold (Ctrl + Option) and make your selection that you want to zoom into. The best part of this method is...
Read more >The mouse wheel + zoom/scroll tips I figured out after coming ...
Hold OPT+CMD and move the mouse scroll wheel to zoom in/out on your track/midi region. Hold OPT and move the mouse scroll wheel...
Read more >Speed Up Your Zooms in Logic Pro With These 2 Keys
Instead, just hold Control and Option to change your current Mouse Tool to the Zoom Tool. Commit these 2 key commands to memory,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks! I’ll get started on a plugin when I have time and post an update here in a few days.
Related to #1860 #1820