Coder Social home page Coder Social logo

Comments (5)

nevcos avatar nevcos commented on July 17, 2024

I've fixed this issue changing mouseMoveHandler code, please test-it with above code:

From bfc38051ba3eaca73a56ce5e4271c53d20a17e6d Mon Sep 17 00:00:00 2001
From: Filipe Costa <[email protected]>
Date: Mon, 1 Dec 2014 22:43:19 +0000
Subject: [PATCH] Fix #60 - Drag position is calculated incorrectly when parent
 elements has margins/paddings and defined position.

---
 src/ui-layout.js | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/ui-layout.js b/src/ui-layout.js
index cd2b0ca..a2f256d 100644
--- a/src/ui-layout.js
+++ b/src/ui-layout.js
@@ -108,10 +108,13 @@ angular.module('ui.layout', [])
     };

     ctrl.mouseMoveHandler = function(mouseEvent) {
-      lastPos = mouseEvent[ctrl.sizeProperties.mouseProperty] ||
+      var lastMousePos = mouseEvent[ctrl.sizeProperties.mouseProperty] ||
       (mouseEvent.originalEvent && mouseEvent.originalEvent[ctrl.sizeProperties.mouseProperty]) ||
       (mouseEvent.targetTouches ? mouseEvent.targetTouches[0][ctrl.sizeProperties.mouseProperty] : 0);

+      var lastRelativePos = lastMousePos - $element.offset()[ctrl.sizeProperties.flowProperty];
+      lastPos = lastRelativePos;
+
       //Cancel previous rAF call
       if(animationFrameRequested) {
         window.cancelAnimationFrame(animationFrameRequested);
-- 
1.9.4.msysgit.2

Thanks!

from ui-layout.

nevcos avatar nevcos commented on July 17, 2024

Just to clarify, $element.offset function is the jQuery offset function, but jQuery is not defined as a dependency, so this could be a problem.

from ui-layout.

mindjuice avatar mindjuice commented on July 17, 2024

I've provided a similar patch in #52 that does not require jQuery.

from ui-layout.

jbro-io avatar jbro-io commented on July 17, 2024

@nevcos can you confirm v1.0.5 fixes this issue? Thansk!

from ui-layout.

nevcos avatar nevcos commented on July 17, 2024

Hi @jbroquist, sorry about the (very) late response.

Successfully tested with master and version 1.0.5 👍

Thanks!

from ui-layout.

Related Issues (20)

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.