Code Monkey home page Code Monkey logo

godot-smooth-scroll's Introduction

Usage

Add the SmoothScroll node to all windows that need smooth scrolling. The node works only on one window at a time and does not work on embedded windows. If some specific Control shoudln't be smooth scrolling, add the SmoothScrollIgnore node to it.

Enabling the addon will automatically add a SmoothScroll node as an autoload and add smooth scrolling to the godot editor.

Explanation

This addon enables smooth scrolling by interecpting non-smooth scroll events and turning them into smooth ones. This is done with the _input() callback, accept_event() and Input.parse_input_event().

If it receives a InputEventMouseButton in _input, it will check if it has a (smooth) factor. If it doesn't, it will set its factor to 0 to prevent it from being used in normal Control nodes. Then it will record the events scroll amount in a variable _needed_scroll, to then later split the needed scroll amount up into smaller chunks, which will make scrolling smoother. That is done in _process(), in which it will create new InputEventMouseButton's with a modified factor to be parsed.

Known problems / Limitations

  • This will increase the amount of scroll events, which might mess with components that work with single scroll events. To work around this, you can add the SmoothScrollIgnore node to the Control node that should not receive smoothed scroll events. You can also also check for smoothed scroll events with event.button_mask & 2048 or disabled (factor 0) scroll events with event.button_mask & 4096
  • This might not report the correct mouse location if the window is scaled with the viewport expand mode.
  • This will not work on embedded windows.

godot-smooth-scroll's People

Contributors

kiisu-master avatar

Stargazers

Vovkiv avatar

Watchers

 avatar

godot-smooth-scroll's Issues

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.