I was working on a project which required to control Hype animation timelines using a slider. There is an HTML widget on top of that slider, but the problem is that every time I drag the slider and put my cursor over the HTML widget, it locks the cursor. Sometimes, it makes the whole scene irresponsive.
I’m not sure what is causing the issue. Any suggestion is welcome. Thanks in advance!
Added a slightly edited hype project that I got from this forum:
Maybe it helps creating a new timeline instead of using the always running main timeline? That pause action at the start may be interfering with your project.
Other then that I had no lock ups from Daniel’s version here.
@dr.stormer The issue is that HTML widgets (essentially iframes) have their own events and therefore when you click, mouseover, mousedown, etc, etc on top of the widget then the “pointer events” for that “iframe” kick in preventing the rest of the documents pointer events from working.
I don’t know the reason for using a HTML widget here but maybe you can use a normal rectangle element? or, if you don’t need pointer events on the widget then just check the “ignore all pointer events” checkbox in the Actions inspector for the widget.
If you do need the events and a widget then you’re gonna have to do some smart JS to change the pointer events when perhaps mousing over and mousing out of the HTML widget.
Here’s generic code that will disable and re-enable pointer events for all iframes within the Hype document based on the drag phase. It can be added as a Run JavaScript… function chained to the On Drag handler:
var hypeDocumentElement = hypeDocument.getElementById(hypeDocument.documentId());
if(event['hypeGesturePhase'] == hypeDocument.kHypeGesturePhaseStart) {
// on start, make all iframes not respond to pointer events
var iframes = hypeDocumentElement.getElementsByTagName("iframe");
for(i = 0; i < iframes.length; i++) {
iframes[i].style["pointer-events"] = "none";
}
} else if(event['hypeGesturePhase'] == hypeDocument.kHypeGesturePhaseEnd || event['hypeGesturePhase'] == hypeDocument.kHypeGesturePhaseCancel) {
// on end, set all iframes back to allowing pointer events
var iframes = hypeDocumentElement.getElementsByTagName("iframe");
for(i = 0; i < iframes.length; i++) {
iframes[i].style["pointer-events"] = "auto";
}
}