Jump to content


Photo

Using mouse wheel to scroll in uniGUI Mobile application on desktop


  • Please log in to reply
2 replies to this topic

#1 Emilio Rueda

Emilio Rueda

    Member

  • uniGUI Subscriber
  • PipPip
  • 20 posts

Posted 02 August 2016 - 07:46 AM

Add this code to CustomMeta property in ServerModule.  ( found in http://stackoverflow...tion-on-desktop)

 

var mouseWheelHandler = function (e) {
    var e = window.event || e,
        el = e.target,
        cmp,
        offset,
        scroller,
        delta,
        _results = [];
    e.preventDefault(); // prevent scrolling when in iframe
    while (el !== document.body) {
        if (el && el.className && el.className.indexOf('x-container') >= 0) {
            cmp = Ext.getCmp(el.id);
            if (cmp && typeof cmp.getScrollable == 'function' && cmp.getScrollable()) {
                scroller = cmp.getScrollable().getScroller();
                if (scroller) {
                    delta = e.detail ? e.detail*(-120) : e.wheelDelta;
                    offset = { x:0, y: -delta*0.5 };
                    scroller.fireEvent('scrollstart', scroller, scroller.position.x, scroller.position.y, e);
                    scroller.scrollBy(offset.x, offset.y);
                    scroller.snapToBoundary();
                    scroller.fireEvent('scrollend', scroller, scroller.position.x, scroller.position.y-offset.y);
                    break;
                }
            }
        }
    _results.push(el = el.parentNode);
    }
    return _results;
};

if (document.addEventListener) {
    // IE9, Chrome, Safari, Opera
    document.addEventListener('mousewheel', mouseWheelHandler, false);
    // Firefox
    document.addEventListener('DOMMouseScroll', mouseWheelHandler, false);
}
else {
    // IE 6/7/8
    document.attachEvent('onmousewheel', mouseWheelHandler);
}


  • 0

#2 AdilsonReis

AdilsonReis

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 07 August 2018 - 11:58 AM

Hello
How do I enable it?
 
but it does not work

  • 0

#3 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 5317 posts

Posted 07 August 2018 - 01:20 PM

Hello,

Which edition are you using?
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users