question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Scroll Zoom Speed Logic

See original GitHub issue

Hello, 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:open
  • Created 4 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Deprecator16commented, Aug 8, 2019

Thanks! I’ll get started on a plugin when I have time and post an update here in a few days.

0reactions
msalsberycommented, Jul 27, 2020

Related to #1860 #1820

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found