logo
down
shadow

Scroll the page when a canvas is touch dragged


Scroll the page when a canvas is touch dragged

By : user2948553
Date : November 14 2020, 04:51 PM
will be helpful for those in need I was able to resolve this by:
Removing e.preventDefault(); Hooking up canvas[0].onselectstart = function () { return false; } to prevent text being selected when the canvas is double-clicked (this was what e.preventDefault() did in the first place) Replacing touchstart with touchend
code :


Share : facebook icon twitter icon
MapBox scroll page on touch

MapBox scroll page on touch


By : Jasper Dil
Date : March 29 2020, 07:55 AM
Hope this helps This example has been improved: the line that was missing is:
if (map.tap) map.tap.disable();
How to prevent polymer scrolling page on touch screen during touch drag and drop procedures on a canvas?

How to prevent polymer scrolling page on touch screen during touch drag and drop procedures on a canvas?


By : Havauk
Date : March 29 2020, 07:55 AM
this one helps. Fortunately, I found the answer here: Using touch events with Createjs / Easeljs
A single line of code was required:
code :
createjs.Touch.enable(stage);
How to use UIScrollview scroll to page when touch button

How to use UIScrollview scroll to page when touch button


By : Olimjon Matniyazov
Date : March 29 2020, 07:55 AM
hope this fix your issue I want a UIScrollView that works like: , suppose the height value of your one page is pageHeight,
code :
CGPoint contentOffset = yourScroll.contentOffset
contentOffset.y = pageHeight * pageIndex;
[yourScroll setContentOffset:contentOffset animated:YES];
Bind canvas to window when canvas is dragged in pyqt

Bind canvas to window when canvas is dragged in pyqt


By : Alex
Date : March 29 2020, 07:55 AM
hope this fix your issue If you want to drag the AppWindow you should register the dragging in this class, instead of the Figure canvas. Inside figure canvas you can then route the drag events to the AppWindow.
The following should work for you, where I did not change much of the code, just rearanged it, added the parent argument to GraphCanvas and let the dragging functions call their parent's functions.
code :
from PyQt4 import QtCore
from PyQt4 import QtGui
from matplotlib.figure import Figure
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas


class GraphCanvas(FigureCanvas):
    def __init__(self, parent = None):
        self.parent = parent
        # The window
        self.fig = Figure(figsize=(5, 5), dpi=100)
        self.ax1 = self.fig.add_subplot(111)
        self.ax1.plot([1,2,3], [1,2,3], linewidth=2, color="#c6463d", label="line1")
        FigureCanvas.__init__(self, self.fig)


    def mousePressEvent(self, event):
        self.parent.mousePressEvent(event)

    def mouseMoveEvent(self,event):
        self.parent.mouseMoveEvent(event)

    def mouseReleaseEvent(self, event):
        self.parent.mouseReleaseEvent(event)


''' End Class '''


class AppWindow(QtGui.QWidget):
    def __init__(self, parent=None):
        super(AppWindow, self).__init__(parent)
        self.setWindowFlags(QtCore.Qt.FramelessWindowHint)

        layout = QtGui.QVBoxLayout(self)
        cpu_canvas = GraphCanvas(self)
        layout.addWidget(cpu_canvas)

        self.draggable = True
        self.dragging_threshold = 5
        self.__mousePressPos = None
        self.__mouseMovePos = None

    def mousePressEvent(self, event):
        if self.draggable and event.button() == QtCore.Qt.LeftButton:
            self.__mousePressPos = event.globalPos()                # global
            self.__mouseMovePos = event.globalPos() - self.pos()    # local
        super(AppWindow, self).mousePressEvent(event)

    def mouseMoveEvent(self, event):
        if self.draggable and event.buttons() & QtCore.Qt.LeftButton:
            globalPos = event.globalPos()
            moved = globalPos - self.__mousePressPos
            if moved.manhattanLength() > self.dragging_threshold:
                # move when user drag window more than dragging_threshould
                diff = globalPos - self.__mouseMovePos
                self.move(diff)
                self.__mouseMovePos = globalPos - self.pos()
        super(AppWindow, self).mouseMoveEvent(event)

    def mouseReleaseEvent(self, event):
        if self.__mousePressPos is not None:
            if event.button() == QtCore.Qt.LeftButton:
                moved = event.globalPos() - self.__mousePressPos
                if moved.manhattanLength() > self.dragging_threshold:
                    # do not call click event or so on
                    event.ignore()
                self.__mousePressPos = None
        super(AppWindow, self).mouseReleaseEvent(event)

''' End Class'''

if __name__ == '__main__':
    import sys
    app = QtGui.QApplication(sys.argv)
    main = AppWindow()
    main.show()
    sys.exit(app.exec_())
disable page scroll on touch pad scroll inside forge viewer in firefox

disable page scroll on touch pad scroll inside forge viewer in firefox


By : user3220395
Date : March 29 2020, 07:55 AM
wish help you to fix your issue I seem to have figured out the issue, the viewer controls bind to the DOMMouseScroll and the mousewheel on the .canvas-wrap element. this is not enough for newer versions of firefox. The controls need to also bind to the "wheel" event which seems to be the standard event for handling mouse wheel action. the following acts as a temporary fix.
code :
document.getElementsByClassName("canvas-wrap")[0].addEventListener( 'wheel', NOP_VIEWER.impl.controls.mousewheel, false);
Related Posts Related Posts :
  • How to change add and remove active class in JavaScript
  • how to toggle a specific div in javascript
  • How to get all the values from multiple keys of an array of object?
  • jQuery bind() unbind() and on() and off()
  • regular expression to find DD Month YYYY from a string
  • How to upload files from web client (HTML/jQuery form) to your Dropbox folder
  • Backbone history and require.js issue
  • Confusion over Classical and Prototypal Inheritance Javascript
  • How to take screen shot of current webpage using Javascript/JQuery?
  • Store meridiem in a variable
  • class declared inside closure vs standard class without closure
  • javascript confirm box always return true
  • dynamically changing the size of font size based on text length using css and html
  • Node.js - Getting the host IP address while on Amazon EC2
  • Confusing CSS, can anyone explain please
  • How to install v8-profiler on Windows 8 (64 bit) using npm?
  • Resolve promise based on another promise
  • google maps adding overlay layer above UI and markers
  • Style specific letter?
  • RangeError: Maximum call stack size exceeded with array.slice
  • node rest client get with local variable
  • If condition not executes while mouse move fastly
  • Count the number of displayed elements in a HTML list
  • Locate JavaScript source code in Emacs
  • Clean, Modular Code vs MV* Frameworks
  • infinite scroll without loading image
  • Backbone: reverse collection order with comparator
  • What do printers ignore?
  • jQuery UI .tabs() Contentless tab?
  • Execute Javascript alert() after page (visually) loaded
  • JavaScript - duplicating array doesn't work
  • Excessive clickable area below image
  • JavaScript Regex: Replace |b| with <b>
  • Unexpected value change in 2D array in JavaScript
  • Function doesnt see parameter as a array of objects
  • jQuery fetch keypress event on chrome and IE
  • How to enable jquery validate localization?
  • Cassandra map collection returned by node.js Helenus looks odd
  • angular ng-repeat with multiple filter options
  • Selecting Children without ID or Class names
  • How to uncheck a group of checkboxes when another checkbox is checked
  • Is hiding content by Javascript or jQuery Worth trying
  • Load XUL resource using javascript
  • XML to HTML text area from server file system
  • set focus() on textbox on form onload
  • es lint '' is assigned a value but never used' eventhough i have used it
  • Can "name" attribute be used for custom VueJS components
  • Get innerHTML of content when it is clicked
  • HTTPS causes CSS animations to not load? Very confused
  • How to hide other div apart from touched div to the band
  • Is global variable assignment atomic on NodeJS?
  • Datepicker onchangemonthyear beforeshowday
  • trying to render html files using jade but it still adresses it as a jade
  • Google Analytics - Understanding and Dissecting the Snippet: What is | | [ ];
  • Replacing "[aA09.b]." to "[aA09.b]\n" in in JavaScript
  • Why wrap a function definition in an immediate function?
  • Enable / disable jQuery script on switching to different tab in a HTML page
  • how can find return variable value outside anonymous function in node js mysql query function
  • Converting 1 to 0001 in javascript array
  • svg viewbox should not resize the text fontSize?
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org