मुझे इस एनीमेशन समस्या के बारे में एक समाधान मिला। मुझे नहीं पता कि यह आपके लिए काम करता है। लेकिन मुझे आपके Jsfiddle में कुछ coding
समस्या मिली।
पहला कोडिंग समस्या।
आपने W3C नियमों का प्रवाह नहीं किया है। button
एक बंद tag
तत्व है। यह कोई भी <img />
<br />
आदि
दूसरा codding मुद्दे की तरह tag
तत्व को बंद नहीं कर रहा है।
आपको position
दिशा CSS
संपत्ति लिखना भूल गया है। position: fixed | absolute | sticky
को left | right | top | bottom
दिशा सेट करने की आवश्यकता है।
मैंने कई बार अपने पहेली का परीक्षण किया क्यों :active
pseudo-class
clicked
के बाद काम नहीं करता है। आपकी पहली animation
से समस्या मिली। animation
और bounceInDown
classes
में transform
संपत्ति शामिल है। animation
तब तक काम नहीं करेगा जब तक कि आप animation
और bunceInDown
classes
हटा दें। तो मुझे उन classes
को हटाने के लिए function
लिखने की आवश्यकता है।
$(function(){
$('#button').on('click', function(){
$(this).removeClass('animated bounceInDown');
});
});
जब मैं उन classes
मैंने देखा बटन की वजह से #button
गायब हो गया है opacity:
0;
है हटा दिया। तो मुझे #button
में opacity: 1;
की आवश्यकता है।
$(function(){
$('#button').on('click', function(){
$(this).addClass('opacity-visible');
});
});
अब एक और मुद्दा मिला। समस्या पहले click
:active
animation
काम नहीं कर रही है। पहले click
की वजह से transform
संपत्ति animation
classes
हटा दी गई है। फिर उन animation
classes
को हटाते समय class
जोड़ने की आवश्यकता है। जोड़े गए class
:active
animation
काम करेगा।
$(function(){
$('#button').on('click', function(){
$(this).addClass('active');
});
});
अब अगले clicked
animation
के लिए button
वापस मूल स्थान पर के लिए active
class
को दूर एक timeOut
function
के लिए सेट करना होगा। अब मैं एक साथ सभी function
लिख सकता हूं।
$(function(){
$('#button').on('click', function(){
$(this).addClass('active opacity-visible');
$(this).removeClass('animated bounceInDown');
setTimeout(function(){
$('#button').removeClass('active');
}, 2000);
});
});
स्नैप की जांच की गई। मुझे उम्मीद है कि यह आपको सबसे अच्छा समाधान करने में मदद करेगा।
setTimeout(function(){
$("#button").addClass("animated bounceInDown");
}, 1000);
$(function(){
\t $('#button').on('click', function(){
\t $(this).addClass('active opacity-visible');
$(this).removeClass('animated bounceInDown');
setTimeout(function(){
\t $('#button').removeClass('active');
}, 2000);
});
});
*:focus{
outline: none !important;
}
*{
-webkit-tap-highlight-color: rgba(0, 0, 0, 0) !important;
}
#button {
position: fixed;
background-color: green;
border: 2px solid rgba(0, 0, 0, 0.15);
border-radius: 4px;
color: white;
cursor: pointer;
height: 20%;
left: 0;
width: 20%;
top: 0;
opacity: 0;
}
#button:active{
background-color: red;
transform: translateX(50%) !important;
/* animation-name: not_existing_animation; */
}
#button.opacity-visible{
opacity: 1;
transition: transform 0.3s ease-in-out 0s;
}
#button.active{
background-color: black;
transform: translateX(50%) !important;
}
/*!
* animate.css -http://daneden.me/animate
* Version - 3.5.2
* Licensed under the MIT license - http://opensource.org/licenses/MIT
*
* Copyright (c) 2017 Daniel Eden
*/
.bounceInDown {
animation-name: bounceInDown;
opacity: 1!important;
}
.animated {
animation-duration: 1s;
animation-fill-mode: both;
}
@keyframes bounceInDown {
from, 60%, 75%, 90%, to {
animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
}
0% {
opacity: 0;
transform: translate3d(0, -3000px, 0);
}
60% {
opacity: 1;
transform: translate3d(0, 25px, 0);
}
75% {
transform: translate3d(0, -10px, 0);
}
90% {
transform: translate3d(0, 5px, 0);
}
to {
transform: none;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<button id="button">Click Me</button>
मैं सुझाव है कि आप करने के लिए animation
के इस प्रकार के लिए :active
css
बारे में नहीं है। MDN पर अधिक विनिर्देशन।
आप प्रत्येक क्लिक पर इस एनीमेशन की ज़रूरत है? –
हां मुझे हर क्लिक पर इसकी आवश्यकता है – wymyszony
क्या आपका मतलब सही है (translateY)? – wymyszony