Note: I am only seeing this behaviour in Chromium. In Firefox I get the mouse movement signals I expect when I mouse over the Elm app.
When I "embed" my Elm program instead of "fullscreen" it, it doesn't give me Mouse.position signals unless I click and drag the mouse in the div in which it is embedded. Even when I move my mouse over the div containing the Elm app, I don't get signals unless I click and drag.
My Elm code is copied directly from http://elm-lang.org/examples/mouse-position :
import Graphics.Element exposing (..)
import Mouse
main : Signal Element
main =
Signal.map show Mouse.position
My HTML is:
<div id="mousepos" style="display: inline-block;"></div>
<script src="mousepos.js"></script>
<script type="text/javascript">
var mousepos = document.getElementById( "mousepos" );
Elm.embed( Elm.Main, mousepos );
</script>
If I click and drag on the div, I see the numbers change, but if I just move my mouse around, they don't change (even if I've clicked once to give the canvas focus).
Am I doing something wrong?
Edit: emphasised I don't see mouse movement even when I move the mouse over the div containing the Elm app.
Edit 2: added note that I only see this in Chromium.
Mouse.position only listens to mouse movements on the top level DOM element making up your Elm app.
You can see this by looking at the source code where Mouse.position is tied to the listening event. It adds the listener to the Elm app DOM node only, not the whole page. Since you're doing Elm.embed(), your node is just the mousepos div, not the whole page.
If you want to respond to mouse positions on the entire page, you'll need to make a port which sends in global mouse position signals from Javascript.
Related
I've had several occasions in my selenium tests where I decided to use Selenium's click_and_hold() (source code here) method on some element. The source code makes it look like it will stay pressed indefinitely but there are definitely some actions, such as a simple click, that cause the held click to be released. Obviously calling release will release the held click too, but does anyone have a grasp on exactly what actions/conditions (either from the script or the page itself) will cause the held click to be released?
I've linked to the documentation for the python bindings, but I assume this would be the same no matter what language is used to write the script. Please let me know if this assumption is incorrect!
release()
release(on_element) releases a held mouse button on an element. If on_element is None releases on current mouse position which is defined as:
def release(self, on_element=None):
"""
Releasing a held mouse button on an element.
:Args:
- on_element: The element to mouse up.
If None, releases on current mouse position.
"""
if on_element:
self.move_to_element(on_element)
if self._driver.w3c:
self.w3c_actions.pointer_action.release()
self.w3c_actions.key_action.pause()
else:
self._actions.append(lambda: self._driver.execute(Command.MOUSE_UP, {}))
return self
release() is invoked by default by different methods of the ActionChains implementation. Some of them are as follows:
release(): Releasing a held mouse button on an element.
drag_and_drop(source, target): Holds down the left mouse button on the source element, then moves to the target element and releases the mouse button.
drag_and_drop_by_offset(source, xoffset, yoffset): Holds down the left mouse button on the source element, then moves to the target offset and releases the mouse button.
click_and_hold()
click_and_hold() holds down the left mouse button on an element.
So you saw it right, the source code confirms the same that it will stay pressed indefinitely unless release() is directly invoked or invoked through other methods. However there can be other actions / events which may cause the hold down left mouse button to be released implicitly. These actions / events can be a result of any of the HTML DOM Events. HTML DOM events allow JavaScript / AjaxCalls to register different event handlers on elements in an HTML document. Some of the mostly encountered events are:
HTML DOM UiEvent: Events that are triggered from the user interface belongs to the UiEvent Object.
onload Event: The onload event occurs when an object has been loaded.
onresize Event: The onresize event occurs when the browser window has been resized.
onscroll Event: The onscroll event occurs when an element's scrollbar is being scrolled.
HTML DOM FocusEvent: Events that occur when elements gets or loses focus, belongs to the FocusEvent Object.
onblur Event: The event occurs when an element loses focus
onfocus Event: The event occurs when an element gets focus
onfocusin Event: The event occurs when an element is about to get focus
onfocusout Event: The event occurs when an element is about to lose focus
The Event Object: All event objects in the DOM are based on the Event Object.
onchange Event: The onchange event occurs when the value of an element has been changed.
HTML DOM MouseEvent: Events that occur when the mouse interacts with the HTML document belongs to the MouseEvent Object.
onmousedown Event: The onmousedown event occurs when a user presses a mouse button over an element.
onmouseup Event: The onmouseup event occurs when a user releases a mouse button over an element.
HTML DOM DragEvent: Events that occur when elements are dragged and/or dropped, belongs to the DragEvent Object.
ondrag Event: The ondrag event occurs when an element or text selection is being dragged.
ondragstart Event: The ondragstart event occurs when the user starts to drag an element or text selection.
HTML DOM TransitionEvent: Events that occur when a CSS transition runs, belongs to the TransitionEvent Object.
transitionend Event: The event occurs when a CSS transition has completed
key_up()
The key_up() method also releases a modifier key. As an example:
ActionChains(driver).key_down(Keys.CONTROL).send_keys('c').key_up(Keys.CONTROL).perform()
This usecase
Without any visibility to your usecase of implementing click_and_hold() it is to be noted that, key_down() is a method which performs a modifier key press and it does not release the modifier key and subsequent interactions may assume it's kept pressed. Note that the modifier key is never released implicitly. Either key_up(theKey) or send_keys(Keys.NULL) must be called to release the modifier.
Generally any action that results in a mouse up event being called.
Click will call a mouse down event and then a mouse up event (As shown in the Code)
Click_and_hold() will only perform the mouse down part. If you then call anything else that triggers the mouse up event, the mouse click will be released.
Remember selenium is just passing a list of actions over to the driver binary that is controlling the browser using the JSON wire protocol. The commands you use in code are translated into JavaScript actions before being passed over the wire so the driver binary controlling the browser probably doesn't have much in the way of context of exactly what the original commands before they were broken down were.
I'm having a trouble with full-screen toggle of videojs HTML5 Player.
Here, I've got two videos on a page (https://yiddishevinkel.com/archives/9555) where the main video looks ok. But the video in sidebar, I'm not able to switch to full screen mode. When i hit the full-screen toggle, It switches to full screen and immediately gets exited from the full screen mode with "Exited fullscreen because fullscreen element was removed from document." warning in Firefox console.
Note that, Issue persist with single instance of video on page and chrome as well.
Without even consulting the fullscreen api documentation, it seems likely from the message you are getting that videojs is replacing an element and you are invoking requestFullScreen on that element or one of its children. An element that does not exist cannot be displayed full screen, therefore the mode exits, a behaviour that is both documented and pretty obvious from the message.
Solution: don't. Wrap it with a div and invoke requestFullScreen on that.
I am having issue with parallax/smooth-scolling and mouse wheel scrolling of Bootstrap modal popup windows.
The Bootstrap modal popup appears when user clicks "Learn More" button.
The modal popup window have the scrollbar. The issue is that user is not able to scroll using mouse wheel because that event is intercepted by parallax/smooth-scolling script.
I am not able to insert code here because the amount of code is too big.
The issue can be reproduced on this website.
Is it possible to solve this issue with adding custom javascript to the website?
I think the issue stems from adding parallax-3d to the body tag which is adding an onscroll event listener to your popups. I can see this from inspecting the events for the popup elements in developer tools.
I would suggest adding parallax-3d to main-container.
<div class="main-container parallax-3d">
Edit: Ok, so the parallax-3d library adds for all elements in the body, irrespective of placement.
I just removed the scroll events for the modals and it works.
Try this to remove scroll events.
$('.foundry_modal').unbind('scroll');
I'm using the fantastic svg-pan-zoom plugin (https://github.com/ariutta/svg-pan-zoom) to pan/zoom my svg element, I want to enable the mouse drag to let use move it.
I have a single elemen inside my svg where I want to prevent the drag because it has a click event and when the user clicks on it sometimes it drag the svg element.
The requested behavior is to drag as standard except when the mouse is down on this element.
I already try with event.stopPropagation() and event.preventDefault() but seems that svg-pan-zoom plugin has its own event management.
How can I prevent the mouse drag?
You can have 2 layers (if you don't need to pan/zoom that element).
Or you can still keep all elements zoomed but only some of them listening for events. Just place everything you want to listen for events in one SVG Group element <g> and set it to listen for events.
Last solution would be to override default events for click/drag and write your own handlers.
I would recommend option 1 if you don't need your element to be zoomed, or option 2 otherwise.
Task: I wanted to create a simple share button which extends to a share section (F,T,G,P) when clicked.
I failed to let the section slide out of the share button - what I really, really wanted - but managed to let a separate ul element slide out on the right side.
The animation worked… until I set the ul to hide initially via $('.networks').hide();
The sections is intended to only show up after a click, but now after the first click it just "pops open" ignoring the configured slide-out. Sliding only works in both directions (open and close) after clicking on it at least once .
I've uploaded an Example here at Codepen.io and as a jsFiddle.
Side note: the demos are behaving a little bit strange since they appear to only show a slide-in fx. The slide-out fx, with which we start, always looks like it pops open - that's not the case, it works after the second click, so you got to focus your eyes to see it (on a normal browser it visibly works better).
PS: Bonus points if you help me make this slide out of the "share" button. Be aware that I only have rudimentary knowledge of Javascript ( * duck and run * ).
Take a look at this fiddle link.
I changed the display property of the buttons to be inline-block instead of inline.
Elements with display inline can not have a width and i think it was the reason why jQuery was not able to animates the Elements width. I also animated the wrap around the ul instead of the ul.
EDIT: made a fast mockup of the thing sliding out of the button. Changed some css to be on the list elements itself instead of on the a elements, just work through the css and I think it will look ok.
edit forgot the link: link