久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

將元素拖放到 iframe 中.可放置區域坐標錯誤,碰

Drag and drop elements into an iframe. Droppable area has wrong coordinates and collisions are wrong(將元素拖放到 iframe 中.可放置區域坐標錯誤,碰撞錯誤)
本文介紹了將元素拖放到 iframe 中.可放置區域坐標錯誤,碰撞錯誤的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我需要在 Web 應用程序中在網頁中的元素和 iframe 內的元素之間實現拖放功能(在您開始抱怨 iframe 之前,出于技術原因,我需要它,這不是一個選項).

I need to implement drag and drop functionalities in a web application between elements present in a web page, and elements inside an iframe (before you start complaining about iframes, I NEED it for technical reasons, it's not an option).

我在頁面中有一些元素可以拖到 iframe 內的目標可放置元素中.

I have elements in the page that can be dragged into target droppable elements inside an iframe.

我已經設法使用 jQuery UI 和 YUI 來做到這一點,盡管這兩個庫都存在相同的問題:目標元素(可放置目標)坐標被誤解,兩個庫考慮的放置區域是錯誤的并且不代表實際的可放置對象,因此拖動的對象和放置的元素之間的碰撞完全搞砸了.這就像圖書館看到可放置元素位于另一個位置,而不是它有效的位置.

I've managed to do it with both jQuery UI and YUI, though both libraries present the same problem: the target element (droppable target) coordinates are misinterpreted, the drop area considered by both libraries is wrong and does not represent the actual droppable object, hence the collisions between the dragged object and the dropped element are messed up entirely. It's like the library sees the droppable element positioned in another place from where it effectively is.

我認為這是由于 iframe 沒有位于頁面的左上角,而是位于中間.我認為這是因為我讀過很多人抱怨這個問題,如果 iframe 位于左上角,問題就會消失.有人建議可以根據screenX和screenY計算droppable元素的坐標,而不是clientX和clientY,這可能是問題的原因,沒有考慮到元素在iframe內,所以坐標不同在 iframe 之外的其他元素之間.

I think this is due to the iframe not being positioned on top-left of page, but in the middle. I think this because I've read many people complaining about this issue and the problem went off if the iframe was top-left positioned. Someone suggest that the coordinates of the droppable element may be calculated based on screenX and screenY, instead of clientX and clientY, and this may be the cause of the issue, not taking into consideration the elements are inside an iframe, and so the coordinates differ between other elements outside the iframe.

所以,由于似乎沒有辦法直接使用庫功能來解決這個問題,而且我真的沒有時間嘗試所有可用的庫,我正在考慮通過修改(修補)來解決這個問題相關庫的內部功能.

So, since it seems there's no way to fix this directly using the library functionalities, and I really don't have time to try every library avaiable out there, I'm thinking about fixing the issue by modifying (patching) the internal functions of the library in question.

問題是:

1) 之前是否有人遇到過這種行為,并設法解決了這個問題?或者,有沒有一個庫可以完美地做到這一點?

1) Did someone experience this behavior before, and managed to fix the issue? Or, is there a library which is able to do this flawlessly?

2) 有沒有辦法使用庫本身的方法和功能來解決這個問題?如果沒有,

2) Is there some way to fix this issue using the methods and functionalities of the library itself? And if not,

3) 有人知道庫的哪個部分計算可放置區域坐標,以便我可以將其修復為最后一個極端選項嗎?

3) Does somebody know which part of the library calculates the droppable area coordinates, so that I can fix it as a last extreme option?

提前致謝,即使是最小的幫助也將不勝感激!

Thanks in advance, even the smallest help will be appreciated!

編輯

這個小提琴演示了這個問題.嘗試將綠色方塊移動到紅色方塊內(位于 iframe 內).你會注意到兩個方塊之間的碰撞是錯誤的.

This fiddle demonstrate the problem. Try to move the green square inside the red square (which is inside an iframe). You will notice the collision between the two squares is wrong.

http://jsfiddle.net/DQdZ9/23/

推薦答案

這不是靈丹妙藥",但我會繼續發布這個作為答案,但我不確定它會有多大價值有你.我在 jQuery UI 中找到了一個可能是您正在尋找的關鍵功能.它在$.ui.ddmanager(拖放管理器)中,函數是prepareOffsets.這一行:

This is not a "silver bullet" , but I'll go ahead and post this as an answer, but I'm not sure how much value it will have for you. I tracked down a key function in jQuery UI that might be what you're looking for. It's in $.ui.ddmanager (the drag and drop manager), and the function is prepareOffsets. This line:

m[i].offset = m[i].element.offset();

似乎是設置偏移量以在元素實際被刪除時使用.這可能是一個根據可放置元素是否是 iframe 的子元素來調整結果偏移量的地方.

seems to be the one that is setting up the offset for use when the element is actually dropped. This might be a place to fiddle with to adjust the resulting offset based on whether the droppable element is a child of the iframe.

它上面還有另一個函數$.ui.intersect,它執行邏輯來查看draggable和droppable是否相互交叉.

There is another function above it $.ui.intersect that performs the logic to see if the draggable and droppable are intersecting each other.

我在最新版本的 jQuery UI 中,文件是 jquery-ui-1.8.14.custom.js 行 2012-2029.如果您獲得單個可放置文件本身,jquery.ui.droppable.js,它位于第 203-220 行.這些是 dev 文件,而不是 min 文件.

I'm in the latest release of jQuery UI, and the file is jquery-ui-1.8.14.custom.js on line 2012-2029. If you get the single droppable file itself, jquery.ui.droppable.js, it's on lines 203-220. And these are the dev files, not the min files.

這篇關于將元素拖放到 iframe 中.可放置區域坐標錯誤,碰撞錯誤的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How can I get my jasmine tests fixtures to load before the javascript considers the document to be quot;readyquot;?(在 javascript 認為文檔“準備好之前,如何讓我的 jasmine 測試裝置加載?) - IT屋-程序員軟件開發技術
What do jasmine runs and waitsFor actually do?(jasmine 運行和等待實際上是做什么的?)
How to provide mock files to change event of lt;input type=#39;file#39;gt; for unit testing(如何提供模擬文件來更改 lt;input type=filegt; 的事件用于單元測試)
How to unit test a chained method using Jasmine(如何使用 Jasmine 對鏈式方法進行單元測試)
How do I inject $rootScope into an AngularJS unit test?(如何將 $rootScope 注入 AngularJS 單元測試?)
Jasmine - How to spy on a function call within a function?(Jasmine - 如何監視函數中的函數調用?)
主站蜘蛛池模板: 大香网伊人 | 国产精品高潮呻吟久久aⅴ码 | 一区二区免费 | 国产在线一区二区 | 国产综合第一页 | 国产91中文 | 久久99精品久久久久久噜噜 | 欧洲视频一区 | 久久久成人一区二区免费影院 | av一区二区三区在线观看 | 精品欧美一区二区三区久久久 | 亚洲一区不卡 | 精品国产91| 日韩成年人视频在线 | av天天干 | 国产一区二区精品在线 | 电影在线 | 成人免费黄色片 | 成人小视频在线观看 | 亚洲精品电影网在线观看 | 国产99久久精品一区二区永久免费 | 九九热精品视频在线观看 | 亚洲精品一区国语对白 | 色网站视频 | 国产日韩一区二区三区 | 国产精品视频在线免费观看 | 91亚洲精 | 欧美中文一区 | 特黄色一级毛片 | 午夜网| 成人免费在线观看 | 国产精品一区二区日韩 | 亚洲视频网 | 免费黄色av | 国产精品视频中文字幕 | 一区免费 | 自拍偷拍中文字幕 | 天啪 | 激情久久网 | 午夜影院视频 | 在线成人av |