logo
down
shadow

Why is this CSS transition only working correctly on the some clicks? How to solve it?


Why is this CSS transition only working correctly on the some clicks? How to solve it?

Content Index :

Why is this CSS transition only working correctly on the some clicks? How to solve it?
Tag : javascript , By : George H.
Date : January 11 2021, 03:34 PM

it helps some times No need to increase z-index in the JS code, simply make the z-index of the transformed element higher in the CSS
$(function() {
  var zValue = 0;

  // event listener detect click
  $(".main ").on("click", "div.flat", function() {
    if (!$(this).hasClass("spinY", "enlarge")) {
      // add class for css transition, enlarge
      $(this).addClass("enlarge");
    }
  });

  // event listener detect end of transition
  $(".main ").on("transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd", "div.flat", function() {
    if ($(this).hasClass("spinY")) {
      $(this).removeClass("enlarge spinY");
    } else {
      $(this).addClass("spinY");
    }
  });
});
.flat,
.labeling {
  position: relative;
  background: white;
  height: 3em;
  width: 3em;
}

.flat,
.flat .rect {
  border: 1px solid silver;
}

.rect {
  position: relative;
  left: 0.2em;
  top: 0.15em;
  height: 70%;
  width: 80%;
  text-align: center;
  line-height: 200%;
}

.available .rect {
  color: white;
  background: #FFAA00;
}

.flat.enlarge {
  transition: all 1s ease;
  transform: rotateY(0turn) scale(3.2);
  z-index: 1;
}

.flat.spinY {
  transition: all 1 linear 1s;
  transform: rotateY(5turn);
  z-index: 1;
}
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

  <div class="main">
    <div class="flat available">
      <div class="rect"></div>
    </div>
    <div class="flat available">
      <div class="rect"></div>
    </div>
    <div class="flat available">
      <div class="rect"></div>
    </div>
  </div>
$(function() {
  var zValue = 0;

  // event listener detect click
  $(".main ").on("click", "div.flat", function() {
    if (!$(this).hasClass("spinY", "enlarge")) {
    
     $(this).css("z-index", ++zValue);
      // add class for css transition, enlarge
      $(this).addClass("enlarge");
    }
  });

  // event listener detect end of transition
  $(".main ").on("transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd", "div.flat", function() {
    if ($(this).hasClass("spinY")) {
      $(this).removeClass("enlarge spinY");
    } else {
      $(this).addClass("spinY");
    }
  });
});
.flat,
.labeling {
  position: relative;
  background: white;
  height: 3em;
  width: 3em;
}

.flat,
.flat .rect {
  border: 1px solid silver;
}

.rect {
  position: relative;
  left: 0.2em;
  top: 0.15em;
  height: 70%;
  width: 80%;
  text-align: center;
  line-height: 200%;
}

.available .rect {
  color: white;
  background: #FFAA00;
}

.flat.enlarge {
  transition: transform 1s ease;
  transform: rotateY(0turn) scale(3.2);
}

.flat.spinY {
  transition: transform 1 linear 1s;
  transform: rotateY(5turn);
}
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

  <div class="main">
    <div class="flat available">
      <div class="rect"></div>
    </div>
    <div class="flat available">
      <div class="rect"></div>
    </div>
    <div class="flat available">
      <div class="rect"></div>
    </div>
  </div>
$(function(){	
	var zValue = 0;
	
	// event listener detect click
	$(".main ").on("click", "div.flat", function(){
		if (!$(this).hasClass("spinY", "enlarge")) {
			// increment z variable & set z-index to it
      $(this).css("z-index", ++zValue);
			// add class for css transition, enlarge
			$(this).addClass("enlarge");
		}
	});

	// event listener detect end of transition
	$(".main ").on("transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd", "div.flat", function(){
    console.log('end!');
		if($(this).hasClass("spinY")) {
			$(this).removeClass("enlarge spinY");
      console.log('Remove class');
		} else {
			$(this).addClass("spinY");
      console.log('add class');
		}
	});
});
.flat, .labeling {
	position: relative;
	background: white;
	height: 3em;
	width: 3em;
}

.flat, .flat .rect {
	border: 1px solid silver;
}

.rect {
	position: relative;
	left: 0.2em;
	top: 0.15em;
	height: 70%;
	width: 80%;
	text-align: center;
	line-height: 200%;
}

.available .rect{
	color: white;
	background: #FFAA00;
}

.flat.enlarge {
	-webkit-transition: all 1s ease;
	transition: all 1s ease;
	transform: rotateY(0turn) scale(3.2);
}

.flat.spinY {
	-webkit-transition: all 1 linear 1s;
	transition: all 1 linear 1s;
	transform: rotateY(5turn);
}
<html>
	<head>
		<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
	</head>

	<body>
		<div class="main">
			<div class="flat available">
				<div class="rect"></div>
			</div>
      	<div class="flat available">
				  <div class="rect"></div>
			  </div>
          <div class="flat available">
            <div class="rect"></div>
          </div>
		</div>
	</body>
</html>
$(function(){	
	var zValue = 0;
	
	// event listener detect click
	$(".main ").on("click", "div.flat", function(){
		if (!$(this).hasClass("spinY", "enlarge")) {
			// increment z variable & set z-index to it
      $(this).css("z-index", ++zValue);
			// add class for css transition, enlarge
			$(this).addClass("enlarge");
		}
	});

	// event listener detect end of transition
	$(".main ").on("transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd", "div.flat", function(){
    console.log('end!');
		if($(this).hasClass("spinY")) {
			$(this).removeClass("enlarge spinY");
      console.log('Remove class');
		} else {
			$(this).addClass("spinY");
      console.log('add class');
		}
	});
});
.flat, .labeling {
	position: relative;
	background: white;
	height: 3em;
	width: 3em;
}

.flat, .flat .rect {
	border: 1px solid silver;
  z-index:0;
}

.rect {
	position: relative;
	left: 0.2em;
	top: 0.15em;
	height: 70%;
	width: 80%;
	text-align: center;
	line-height: 200%;
}

.available .rect{
	color: white;
	background: #FFAA00;
}

.flat.enlarge {
	-webkit-transition: all 1s ease;
	transition: all 1s ease;
	transform: rotateY(0turn) scale(3.2);
}

.flat.spinY {
	-webkit-transition: all 1 linear 1s;
	transition: all 1 linear 1s;
	transform: rotateY(5turn);
}
<html>
	<head>
		<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
	</head>

	<body>
		<div class="main">
			<div class="flat available">
				<div class="rect"></div>
			</div>
      	<div class="flat available">
				  <div class="rect"></div>
			  </div>
          <div class="flat available">
            <div class="rect"></div>
          </div>
		</div>
	</body>
</html>

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Bootstrap Search bar transition not working correctly


Tag : twitter-bootstrap , By : MJRider
Date : March 29 2020, 07:55 AM
To fix this issue I'm trying to get a nice transition effect for my search bar, however every transition starts and ends from a 0px width state for some reason. Does anyone know what could cause this? Thank you. , #searchBox didn't mentioned its width. Try the code below
#searchBox {
  width: 175px;
    border-radius: 15px;
    -webkit-transition: width 0.30s linear 0s;
       -moz-transition: width 0.30s linear 0s;
        -ms-transition: width 0.30s linear 0s;
         -o-transition: width 0.30s linear 0s;
            transition: width 0.30s linear 0s;
}
#searchBox:focus {
    width: 300px;
}

CSS transition not correctly working


Tag : angularjs , By : Francis
Date : March 29 2020, 07:55 AM
will be helpful for those in need I have a weird problem. I have a CSS flip animation with two images. , DEMO
.card .back {
    -webkit-transform: rotateY(180deg);
    -moz-transform: rotateY(180deg);
    -ms-transform: rotateY(180deg);
    -o-transform: rotateY(180deg);
    transform: rotateY(180deg);
    -webkit-transform-style: preserve-3d;
    -moz-transform-style: preserve-3d;
    -ms-transform-style: preserve-3d;
    -o-transform-style: preserve-3d;
    transform-style: preserve-3d;
}

Tag : javascript , By : yarry
Date : March 29 2020, 07:55 AM
seems to work fine You could try the following. Basically just set the margin-left on min-width: 768px to -180px and use padding-left to move the nav back to its original position. Since you are only transitioning margin-left change transition: all 0.3s ease-in-out; to transition: margin-left 0.3s ease-in-out;.
.main-navigation {
    position: fixed;
    height: 100%;
    width: 180px;
    background-color: #000;
    margin-left: -180px;
    padding-left: 0;
    transition: margin-left 0.3s ease-in-out;
    box-shadow: 0px 0px 8px 0px rgba(0, 0, 0, 0.75);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
}


@media screen and (min-width: 768px)
    .main-navigation {
        position: fixed;
        height: 80px;
        width: 100%;
        margin-left: -180px;
        padding-left: 180px;
        background-color: transparent;
        transition: none;
        box-shadow: none;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

On click replace CSS not working correctly on fast clicks


Tag : jquery , By : Arnaud Goudsmit
Date : March 29 2020, 07:55 AM
Does that help I have a site where I have selections boxes divs, when a user clicks on those boxes it reveals a hidden content div and also replaces the background images of the selection box div to a tick. This all works work fine, but if someone clicks fast or clicks in different areas of the selection box div, the background image of the selection box div might show the tick even the the content div is hidden again. I have tried various methods from googling but most seem to relate to a delay on mobile devices. If any one has any ideas, please let me know, also I know my code is probably not the cleanest. The background images are 24kb in size each, could that be it? My code is below: , please review this one:
$(document).ready(function(){
        $(document).on('click','.checkbox',function(){
            var self = $(this),
            target=self.data('target');            
            self.prev('input').trigger('click');            
            $(target).slideToggle(400);
        });
    });
/* Option Boxes */
.checkbox{
    width:100%; 
   height: 50px;
   position:relative;
   float:left;
   background-repeat:no-repeat;
   background-image:url(../Images/Options/Template.png);                 
   background-position: center center; 
   font-size:1.2em;
   color:#000;  
   padding-top:2%;
   text-align:center;
   line-height:-100px;
   margin-right:15%;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    cursor: default;
        }
.myCheckbox+input {
    display:none;
            }


input:checked + .checkbox{
    width:100%; 
    height: 50px;
    background-image: url("../Images/Options/Template-Tick.png");                    
    color:#999;
            }

/* Option Boxes */

.Content_Selection_Holder{
    position:relative;
    float:left;
    width:100%;
    height:auto;    
}
.Content_Selection_Boxes{
    position:relative;
    float:left;
    width:33%;
    height:33%; 
    font-size:90%;
}
.Content_Answer_Holder{
    position:relative;
    float:left;
    width:100%;
    height:auto;
    margin-top:5%;  
}
.Content_Answer_Box{
    position:relative;
    float:left;
    width:96%;
    padding:2%;
    height:auto;
    display: none;
}
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>

<div class="Content_Selection_Holder">

            <div class="Content_Selection_Boxes">
            <label class="myCheckbox"></label>
            <input type="checkbox" name="test"/>
            <div class="checkbox" data-target="#sb1"> Content1</div>
            </div>
            <div class="Content_Selection_Boxes">
            <label class="myCheckbox"></label><input type="checkbox" name="test"/><div class="checkbox" data-target="#sb2">Content2</div></div>
            <div class="Content_Selection_Boxes">
            <label class="myCheckbox"></label>
            <input type="checkbox" name="test"/><div class="checkbox" data-target="#sb3">Content3</div></div>

            </div> <!-- Question Holder-->

            <div class="Content_Answer_Holder">


            <div class="Content_Answer_Box" title="Some content 1" id="sb1">
            Some content 1
            </div>

            <div class="Content_Answer_Box" title="Content2" id="sb2">
            Some content 2         
            </div>

            <div class="Content_Answer_Box" title="Content3" id="sb3">
Some content 3          
            </div>

Second hover transition for scale on <img> tag not working correctly


Tag : css , By : msugar
Date : March 29 2020, 07:55 AM
wish helps you You have just forgotten to put a dot
Like .image-area and problem will be solved:
   main#wrap > .page > .group > section.large-poster:hover > .image-area > img {
      transform:scale(1.2,1.2)
   }
Related Posts Related QUESTIONS :
  • Wrapping lists into columns
  • How to keyboard down or up between dropdown "options"?
  • Http Auth in a Firefox 3 bookmarklet
  • How can I turn a string of HTML into a DOM object in a Firefox extension?
  • Call ASP.NET function from JavaScript?
  • JavaScript Troubleshooting Tools in Internet Explorer
  • MAC addresses in JavaScript
  • Capturing TAB key in text box
  • How to set CSS background color of HTML using JavaScript
  • How can I make the browser see CSS and Javascript changes?
  • redux how to use state
  • All data in the db is lost when closing a express based node js server
  • How to convert javascript code for Angular
  • XPath select on child nodes
  • Idle event on mouse move - how to stop script permanently on mouse move
  • Why do I get logic is not defined in this code
  • When I enter a number in the input, the first function starts
  • ES6 imports and node_modules hell
  • How to get css selector of clicked-on element?
  • How to auto input MySQL data (input column 1 data to auto input column 2 data with same column) in php?
  • Appending to Datalist Via Javascript
  • Customizing Material-UI Components with Styled-Components
  • Populate elements with class name using Javascript
  • How to execute promises in batches (first resolving 10, then next 10 and so on)
  • Maximo JS automation script: "importPackage" is not defined
  • How to surround selected text inside textarea with <em> on key combination CTRL+i?
  • Your configured registry does not support audit requests ~ On npm audit
  • What's the Angular equivalent of Vue <slot/>?
  • Iconify icon not updating when "data-icon" set with setAttribute()
  • Javascript newbie stuck with XMLHttpRequest return data
  • How to add obj to to state in my example Redux React
  • Loading "grunt-karma.js" tasks...ERROR >> SyntaxError: Unexpected identifier
  • Why do I get log is not defined
  • get the multiple index of the same string
  • How can I iterate over an Array object by using For IN or FOR OF
  • Launch local executable from web browser
  • How to prepare array of json objects to d3 hierarchical tree structure
  • VueJS - event emitted - show HTML before other calculations
  • Export SASS/SCSS variables to Javascript without exporting them to CSS
  • How to attach an event handler only once continuously
  • How to make button open a link in new tab in JavaScript?
  • Find range from the javascript object
  • How can I use my jQuery code as JavaScript?
  • How to show 5 images in a 2 row slider with bxslider
  • How to convert stream into variables in typescript
  • Three.js custom shader error on Chrome GL_INVALID_OPERATION: Active draw buffers with missing fragment shader outputs
  • My JavaScript doesn't work. How can I solve this problem?
  • Why is this async function is running synchronously?
  • Get updated variable from within react hook before return
  • I want to show all image preview but whenever I upload a new one the old one is gone
  • Would I be able to give access to specific electron APIs safely?
  • Why several clicks fire for each instance of a Class?
  • cant grab value from div using attr()
  • Make web service not accessible by browser?
  • Select DOM elements within template
  • How to customize angular ui-grid row background color?
  • Binding data in two respective $scope in AngularJS, how?
  • react put some props after import class
  • Variable is distributed among same components
  • switch class in jQuery/JavaScript for active/inactive state
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com