Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve iframe support #313

Merged
merged 2 commits into from
Nov 18, 2015
Merged

Improve iframe support #313

merged 2 commits into from
Nov 18, 2015

Conversation

taye
Copy link
Owner

@taye taye commented Nov 15, 2015

Event listeners are no longer automatically added to the parent window if the script is loaded in an iframe with a parent of the same origin to avoid potential memory leaks. preventDefault is no longer called on down events with the 'auto' setting. This allows mouse move and up events to be fired on the iframe even when the mouse is dragged outside the iframe borders and over the parent document.

interact.addDocument(document) and interact.removeDocument(document) methods have been added to allow listening to different documents, e.g:

// try to listen to events on the parent document if this is an iframe
try {
  if (window.frameElement) {
    const parentDoc = window.frameElement.ownerDocument;
    const parentWindow = parentDoc.defaultView;

    interact.addDocument(parentDoc);
    parentWindow.addEventListener('unload', function () { interact.removeDocument(parentDoc); });
  }
}
catch (error) {}

Close #311
Close #312

 - Add `interact.addDocument` and `interact.removeDocument` methods
 - Don't try to listen to the parent frame
Don't prevent down events. This allows iFrames to "capture" mouse
movement. Selection will no longer be prevented in Firefox.

Adjust when checkAndPreventDefault is called from pointer event listener
methods.
@taye
Copy link
Owner Author

taye commented Nov 15, 2015

@sixinli I've made a more thorough fix for you issue. Please try building this branch to see if it works and if any other problems appear.

@sixinli
Copy link

sixinli commented Nov 17, 2015

Hi @taye thanks for the fix! I am trying to test it out, but for some reason I keep getting

Uncaught TypeError: domUtils.isElement is not a function 

Is there anything that I should be aware of in order to test it out?

@sixinli
Copy link

sixinli commented Nov 18, 2015

Hi @taye, the fix works in my local (no more mem leak yay!) after rebasing on top of master with your recent commit. Thanks a ton again for pushing this forward!

@taye taye merged commit fc595bb into master Nov 18, 2015
@taye
Copy link
Owner Author

taye commented Nov 18, 2015

Sorry I forgot to mention the commit yesterday. I'm glad you spotted it early. Thanks for reporting and testing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants