How to prevent mouseenter event action with jQuery
Tags: javascript,jquery,css,css-animations
Problem :
I have this simple mouseenter : mouseleave action:
call = $('.js-call');
call.on({
mouseenter: function(e){
// animation
e.stopPropagation();
},
mouseleave: function(e){
// animation
}
});
In this action i have two CSS animations, which have a duration of 300ms. How can I prevent mouseover event for animation end, and fire it again if i'm properly on call element. When i moving fast on my call element action call many times. How to prevent it? Thx for help.
Solution :
I would go with placing timeouts on both events, and activate the animation only if at the end of that timeout you still meet a condition. Something like that:
var timeoutIn, timeoutOut, delay = 300;
$element.hover(
function() {
if (timeoutOut){
clearTimeout(timeoutOut);
}
timeoutIn = setTimeout(function() {
// ##################
// 'MOUSEENTER' STUFF GOES HERE
// ##################
}, delay);
},
function() {
if (timeoutIn){
clearTimeout(timeoutIn);
}
timeoutOut = setTimeout(function() {
// ##################
// 'MOUSELEAVE' STUFF GOES HERE
// ##################
}, delay);
}
);
Update: I've just created a jQuery plugin called jQuery.hoverDelay.js, you can check it out here: jQuery hoverDelay.js
CSS Howto..
Change your css to this: #header_contain{ width:935px; height: 135px; background-image: url('bg.gif'); background-repeat: repeat-x; background-color:#E42323; } ...
If you are wanting to add more options to the styles then you need to edit the following file ckeditor/plugins/styles/styles/default.js OR see the documentation for doing so here http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Styles OR...
Try this: $(document).ready(function() { $("#showButton").click(function() { $("#text").show(); }); $("#hideButton").click(function() { $("#text").hide(); }); }); #text { display: none; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <button...
You can put your project-common templates in Project/templates and add the /path/to/Project/templates to your TEMPLATE_DIRS setting in your settings.py file. prepend the root to everything else, so it gets searched...
Marc's answer is right, but in order for it to work you need to add "position: relative;" on the ".parent-div". Otherwise the ".horizontal-scrollbar-div" would position itself according to the body...
The reason your CSS is not working is due to two small errors. First, .head.hover is defining two Class selectors .head and .hover whereas you really want the :hover user...
Script: //Nested Side Bar Menu (Mar 20th, 09) //By Dynamic Drive: http://www.dynamicdrive.com/style/ var menuids=["sidebarmenu1"] //Enter id(s) of each Side Bar Menu's main UL, separated by commas var defaultDelay = 0;...
You don't need to use a pseudo-element here as you are using an actual image. All that is need is to use the image as a background to the link...
Simply add the images you want to display inside the respective <div>: $(document).ready(function() { $("select").change(function() { $("select option:selected").each(function() { if ($(this).attr("value") == "Oone") { $(".box").hide(); $(".red").show(); } if ($(this).attr("value") ==...
Here is a fiddle: https://jsfiddle.net/u3urw5wy/ Add in background-image:url(AddImageUrlHere) to replace background-color: #fff; as below: #progressbar > div { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;...
You can do this with a click listener on the radios and using the next function: $('.row input[type="radio"]').on('click', function() { $('.row input[type="text"]').prop('disabled', true); //disable all text input $('.row input[type="radio"]').not(this).prop('checked', false);...
I eventually managed to find what I was looking for by using the following code, which seemed to be alot simpler. (function($) { $("#menu-main-menu > .menu-parent-item").hover(function(){ $('#menu_overlay').fadeToggle(); }); })(jQuery); Although...
What about a position: fixed; header in @media print? That would force a header on each printed page. Something like: @media screen { .print-header { display: none; } } @media...
seems you have to also style the 'context-menu'. it worked by adding: .context-menu { -fx-background-color: #3c3f41; -fx-border-color: #555555; -fx-border-style: solid; -fx-border-width: 1px; } This and this answers on SO helped...
Looks like you need to clear your floats. Enclose all <div class="row_item"> ... </div> in a parent DIV and give apply following CSS: #row_items { width:100%; overflow:hidden; } OR After...
You can use Jquery UI link here https://jqueryui.com/datepicker/ And style it just like styling a table, see fiddle for an example: https://jsfiddle.net/DIRTY_SMITH/rupbwpx0/ HTML and JQuery <p>Date: <input type="text" id="datepicker"></p> <script>...
I didn't find a proper CSS solution for my case and switched to JS (jQuery): $('.sameHeightWrapper').each(function() { var highestContainer = 0; $('.sameHeightContainer', this).each(function() { if($(this).height() > highestContainer) { highestContainer =...
element.style in Firebug is the style applied to the element, for exemple <span style="padding: 10px;">My text</span> element.style will have element.style { padding: 10px; } to override, the best way is...
Here is an updated snippet: http://jsfiddle.net/Lrc4h/3/ First of all you need to know that when you're using position: absolute the element will position with absolute coordinates based on the first...
You should just use a single gradient like in the below snippet with the start and end as transparent. Explanation: transparent 0% means the gradient starts with transparent color #8C8C8C...
If you are talking about serverside you should to add property to your control and method to detect if it's specified page public string CurrentPageName { get; set; } public...
Normal CSS does not support inheritance; you need to add the child's selector to the parent's ruleset: #edButtonHTMLChild, #edButtonHTML{ styles... } or use Javascript to apply the same styles....
//Need exact selector like if class is sampleclass then className='.sampleClass' var classFinder = function (className) { $.each(document.styleSheets, function (index, cssFile) { if (cssFile.href) var path = cssFile.href.toString(); var classes =...
I think I have what you want here. In the css I have added some selectors for a clearfix class, which is very common. It looks like this: .clearfix:before, .clearfix:after...
Change this: return CurrentText + " " + SelectedCountry; to this: return CurrentText + " <span>" + SelectedCountry + "</span><br/>"; Then apply the CSS on the span tag. Here is...
Just use ids i.e. <div class="container"> <nav class="navbar navbar-default navbar-fixed-top"> <h1>Feed.me</h1> <img src="img/hat.png" id="image1"></img> <img src="img/ware.png" id="image2"></img> Then #image1 { ... } #image2 { ... } img { .... common...
This is simply a case of markup. Firstly, your class names 1, 2 and 3 are not correct. A class can never begin with a number. Secondly, wrap your images...
Set bottom padding of .s-inn-mid to 0 Add bottom left and right border-radius 5px to the black div. border-radius: 0 0 5px 5px I'd tell you it exactly in...
There's a couple of solutions, depending on the details of what you want: If the spaces are going to be small, and you want the background everywhere on the entire...
I found that you can make use of the white-space css property: white-space: normal; And it will break the words as normal text. Hope it helps....