i'm making an animation that show the menu by squentially giving delays. below is my code (twin.macro + emotion).
const Menu = ({ onClose }: Props) => {
return (
<>
<div className="absolute top-0 left-0 w-full h-screen z-menu">
<StaticImage className="w-full h-screen" src="../../static/images/bg-main.png" alt="배경" />
</div>
<div className="absolute top-0 left-0 w-full h-screen bg-menu z-menu">
<button className="absolute top-4 right-4 text-white hover:text-gray-200" onClick={onClose}>
<CloseIcon />
</button>
<Responsive className="py-20">
/* menu */
<ul className="flex flex-col items-start gap-9 overflow-hidden">
<Item>
<Link to="/about">About</Link>
</Item>
<Item>
<Link to="/project">Project</Link>
</Item>
<Item>
<Link to="/story">Story</Link>
</Item>
<Item>
<Link to="/group">Group</Link>
</Item>
</ul>
</Responsive>
</div>
</>
);
};
export default Menu;
const showMenu = keyframes`
from {
transform: translateX(-100%);
}
to {
transform: translateX(0);
}
`;
const Item = styled.li`
${tw`-translate-x-full text-4xl font-bold text-white transition will-change-transform hover:text-gray-200`};
&:nth-of-type(1) {
animation: ${showMenu} 0.3s ease-in-out forwards;
-webkit-animation: ${showMenu} 0.3s ease-in-out forwards;
}
&:nth-of-type(2) {
animation: ${showMenu} 0.3s ease-in-out 0.1s forwards;
-webkit-animation: ${showMenu} 0.3s ease-in-out 0.1s forwards;
}
&:nth-of-type(3) {
animation: ${showMenu} 0.3s ease-in-out 0.2s forwards;
-webkit-animation: ${showMenu} 0.3s ease-in-out 0.2s forwards;
}
&:nth-of-type(4) {
animation: ${showMenu} 0.3s ease-in-out 0.3s forwards;
-webkit-animation: ${showMenu} 0.3s ease-in-out 0.3s forwards;
}
`;
it works well in desktop browsers and ios safari, but animation breaks off in ios chrome. is it a bug? any way solution?
i want it to work properly on ios chrome.
I think the problem comes from will-change.
As per MDN doc, it is intended to be used as a last resort. So maybe Google took it off to avoid performance problems.
Consider using transform property instead.
Hope it helps
Related
I have a bootstrap 5 menu outside the canvas and I want to change the hamburger icon when closing and opening the menu so that a cross and the hamburger appear, but I can't do it
<nav id="main-nav" class="navbar navbar-expand-md navbar-dark bg-primary nav-menu-
home" aria-labelledby="main-nav-label">
<h2 id="main-nav-label" class="screen-reader-text">
<?php esc_html_e( 'Main Navigation', 'understrap' ); ?>
</h2>
<div class="<?php echo esc_attr( $container ); ?>">
<!-- <button type="button" class="btn-close btn-close-white text-reset" data-bs-
dismiss="offcanvas"
aria-label="Close"></button> -->
<!-- data-
toggle="modal" data-target="#menuModal" -->
<button class="navbar-toggler colapsed" type="button" data-bs-toggle="offcanvas" data-
bs-target="#navbarNavOffcanvas" aria-controls="navbarNavOffcanvas" aria-
expanded="false" aria-label="<?php esc_attr_e( 'Toggle navigation', 'understrap'
); ?>">
<span class="toggler-icon top-bar"></span>
<span class="toggler-icon middle-bar"></span>
<span class="toggler-icon bottom-bar"></span>
</button>
<!-- <button type="button" class="btn-close text-reset" data-bs-
dismiss="offcanvas" aria-label="Close"></button> -->
<div class="offcanvas offcanvas-start bg-primary" tabindex="-1"
id="navbarNavOffcanvas">
<div class="offcanvas-header justify-content-end">
<button type="button" class="btn-close btn-close-white text-reset" data-
bs-dismiss="offcanvas" aria-label="Close"></button>
</div><!-- .offcancas-header -->
<!-- The WordPress Menu goes here -->
<?php
wp_nav_menu(
array(
'theme_location' => 'primary',
'container_class' => 'offcanvas-body ',
'container_id' => '',
'menu_class' => 'navbar-nav justify-content-end flex-grow-1 pe-
3',
'fallback_cb' => '',
'menu_id' => 'main-menu',
'depth' => 2,
'walker' => new Understrap_WP_Bootstrap_Navwalker(),
)
);
?>
</div><!-- .offcanvas -->
</div><!-- .container(-fluid) -->
</nav><!-- .site-navigation -->
CSS
.navbar-toggler {
border: 0 !important;
}
.navbar-toggler:focus,
.navbar-toggler:active,
.navbar-toggler-icon:focus {
outline: none !important;
box-shadow: none !important;
border: 0 !important;
}
/* Lines of the Toggler */
.toggler-icon{
width: 30px;
height: 3px;
background-color: #e74c3c;
display: block;
transition: all 0.2s;
}
/* Adds Space between the lines */
.middle-bar{
margin: 5px auto;
}
/* State when navbar is opened (START) */
.navbar-toggler .top-bar {
transform: rotate(45deg);
transform-origin: 10% 10%;
}
.navbar-toggler .middle-bar {
opacity: 0;
filter: alpha(opacity=0);
}
.navbar-toggler .bottom-bar {
transform: rotate(-45deg);
transform-origin: 10% 90%;
}
/* State when navbar is opened (END) */
/* State when navbar is collapsed (START) */
.navbar-toggler.collapsed .top-bar {
transform: rotate(0);
}
.navbar-toggler.collapsed .middle-bar {
opacity: 1;
filter: alpha(opacity=100);
}
.navbar-toggler.collapsed .bottom-bar {
transform: rotate(0);
}
/* State when navbar is collapsed (END) */
/* Color of Toggler when collapsed */
.navbar-toggler.collapsed .toggler-icon {
background-color: #777777;
}
Please use the following tutorial https://jsfiddle.net/8xvaozm2/1/
but it is being used with toggle navigation and not with off canvas, does anyone know how it could be done?
there is a .show class that shows the menu when clicking, I used it but it didn't work for me
HTML:
<svg width="400" height="110"
style="background:red">
<rect id="rectangle" width="300" height="100"
style="fill:rgb(0,0,255);stroke-width:3;stroke:rgb(0,0,0)" />
</svg>
<div id="firstDiv"
style="width:100px;height:100px; background:green">
</div>
jQuery:
jQuery('#firstDiv').resizable({
handles: 'se',
animate: true,
alsoResize: '#rectangle',
})
With this sample, The rect inside svg always starting from x=0, y=0 when we resize firstDiv.
Rect has to start from where it was its last starting/ending position not from zero
jquery ui version : jQuery UI - v1.12.1
In our resizable method add following code
jQuery('#firstDiv').resizable({
handles: 'se',
animate: true,
alsoResize: '#rectangle',
resize: function (event, ui) {
document.querySelector('#rectangle').style.width = ui.size.width;
document.querySelector('#rectangle').style.height = ui.size.height;
}
});
Now everything works fine
When I click on the pop up link it turns blue but nothing popup. I would like to know what I am doing wrong. Do I need to refresh the navbar? I know that jquery mobile events need to be refreshed. Should I use the listview('refresh') ?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Customer Chooses Beer Quantity</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.3/jquery.mobile.min.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.3/jquery.mobile.min.js"></script>
<script>
$(document).on('pagebeforeshow','#index', function(){
start_beer_quantity_from_0();
//hide the ui loader
$("#index").loader().loader("option", "disabled", true );
//ajax call to beers
function start_beer_quantity_from_0(){
//form variables
var beer_count = 0;
var formData = {beer_count:beer_count};
ajax_update_content_when_page_is_loaded_beer_quantity(formData);
}
function ajax_update_content_when_page_is_loaded_beer_quantity(formData){
$.ajax({
url : '<?php echo base_url()."index.php/drink_cart/customer_chooses_beer_quantity"; ?>',
async : true,
type : "POST",
cache : false,
data : formData,
dataType: "html",
success : function(data){
//alert($.trim(data));
$('.display_beer_count').html(data);
},
error: function (jqXHR, textStatus, errorThrown){
$('#server_message_error_jqXHR').html("here is the jqXHR"+jqXHR);
$('#server_message_error_textStatus').html("here is the textStatus "+textStatus);
$('#server_message_error_errorThrown').html("here is the errorThrown"+errorThrown);
}
});
return false;
}
});
$(document).on('click','.beers', function (event){
var beer_quantity = $(this).find(".beer_quantity").val();
var beer = $(this).find(".beer").val();
//form variables
var formData = {
beer_quantity:beer_quantity,beer:beer
};
submit_ajax_form_add_beer(formData);
event.preventDefault();
function submit_ajax_form_add_beer(formData){
$.ajax({
url : '<?php echo base_url()."index.php/drink_cart/customer_chooses_beer_quantity"; ?>',
async : true,
type : "POST",
cache : false,
data : formData,
dataType: "html",
success : function(data){
// alert("Beer posted");
$('.display_beer_count').html($.trim(data));
},
error: function (jqXHR, textStatus, errorThrown){
alert("There is not internet connection. Please check your internet connection");
$('#server_message_error_jqXHR').html("here is the jqXHR"+jqXHR);
$('#server_message_error_textStatus').html("here is the textStatus "+textStatus);
$('#server_message_error_errorThrown').html("here is the errorThrown"+errorThrown);
}
});
return false;
}
});
</script>
</head>
<body >
<div data-role="page" id="index" >
<div data-role="popup" id="settings_popup_beer_quantity" data-position="right">
<ul data-inset="true" data-role="listview" data-theme="a" data-divider-theme="b" style="min-width:210px;">
<li data-role="list-divider">Settings</li>
<li data-icon="false"><?php echo anchor('login/logout/','Logout', array('title'=>"Logout", "rel" =>"external"));?></li>
<li data-icon="false"><?php echo anchor('customer_settings/','Settings',array('title'=>"Settings","rel" =>"external"));?></li></ul></div>
<div style="float:left;">
<img class="small_logo" border="0" src="<?php echo $this->config->base_url();?>images/small_logo.png" alt="cup Bar Express" />
</div>
<div data-role="header" style="width:100px;float:right;" data-position="right">
<div class="settings_button_quantity" data-role="navbar">
<ul>
<li>Settings</li>
</ul>
</div>
</div>
<div style="clear:both;"></div>
<div role="main" class="ui-content" id="index">
<div class="background_image">
<div class="ui-grid-solo" id="title">QUANTITY</div>
<ul data-role="listview" data-split-theme="a" data-inset="true">
<?php
if(isset($beer_quantity_button)){
echo $beer_quantity_button;
}
?>
</ul>
</div>
</div>
<style type="text/css">
.ui-listview>li h1, .ui-listview>li h2, .ui-listview>li h3, .ui-listview>li h4, .ui-listview>li h5, .ui-listview>li h6{
font-family:'RNS Camelia';
text-shadow: none;
color : black !important;
font-weight: 700;
font-size : 33px;
}
li h1 .display_beer_count{
color:white;
}
.ui-listview>.ui-li-static, .ui-listview>.ui-li-divider, .ui-listview>li>a.ui-btn{
padding-right:18px;
padding-left :18px;
text-align :center;
background :transparent !important;
}
button.ui-btn.beer_quantity_button{
border :none;
color : black !important;
background: #D6DE23 !important;
}
.ui-listview>li h1.add_beer_to_cart_letters {
color:white !important;
}
button.add_beer_to_cart {
background: transparent !important;
}
#font-face {
font-family:'RNS Camelia';
font-style : normal;
font-weight: 900;
src : local('RNS Camelia'), url(<?php echo $this->config->base_url();?>fonts/RNS_Camelia.otf);
}
#font-face{
font-family:'Simply City Light';
font-style : normal;
font-weight: normal;
src : local('Simply City Light'), url(<?php echo $this->config->base_url();?>fonts/siml023.ttf);
}
.settings_button_quantity{
width :100px;
height :22px;
float :right;
}
a .settings_popup_link_quantity{
height:22px;
}
.ui-content .ui-listview-inset, .ui-panel-inner>.ui-listview-inset{
margin:0;
}
#title{
text-shadow : none!important;
margin-bottom: 11px;
width : 100%;
font-size : 52px !important;
font-family :'RNS Camelia' !important;
color : #D6DE23 !important;
padding-left : 5%;
}
.background_image{
width :100% !important;
padding-bottom:160px !important;
margin-left :auto !important;
margin-right :auto !important;
display :block;
background :url(<?php echo $this->config->base_url();?>images/beer_cup.png) no-repeat;
z-index :-21;
}
.ui-page{
background-image :url('<?php echo $this->config->base_url();?>images/background.png') !important;
width :100%;
background-size :100% 100%;
background-repeat:no-repeat;
}
.small_logo{
padding-top: 4px;
width : 138px;
height : 52px;
}
#settings_popup_beer_quantity li a,#settings_popup_beer_quantity,.ui-navbar li:last-child .ui-btn {
color :black !important;
font-family:'Simply City Light'!important;
}
#settings_popup_beer_quantity .ui-li-divider{
background:black!important;
}
</style>
</div>
</body>
</html>
I copied your code into a fiddle here and it appears to be working for me. at least the popup shows up when I click the link.
https://jsfiddle.net/2y9ouhzb/
<div data-role="page" id="index">
<div data-role="popup" id="settings_popup_beer_quantity" data-position="right">
<ul data-inset="true" data-role="listview" data-theme="a" data-divider-theme="b" style="min-width:210px;">
<li data-role="list-divider">Settings</li>
<li data-icon="false">
<?php echo anchor( 'login/logout/', 'Logout', array( 'title'=>"Logout", "rel" =>"external"));?></li>
<li data-icon="false">
<?php echo anchor( 'customer_settings/', 'Settings',array( 'title'=>"Settings","rel" =>"external"));?></li>
</ul>
</div>
<div style="float:left;">
<img class="small_logo" border="0" src="<?php echo $this->config->base_url();?>images/small_logo.png" alt="cup Bar Express" />
</div>
<div data-role="header" style="width:100px;float:right;" data-position="right">
<div class="settings_button_quantity" data-role="navbar">
<ul>
<li>Settings
</li>
</ul>
</div>
</div>
<div style="clear:both;"></div>
<div role="main" class="ui-content" id="index">
<div class="background_image">
<div class="ui-grid-solo" id="title">QUANTITY</div>
<ul data-role="listview" data-split-theme="a" data-inset="true">
<?php if(isset($beer_quantity_button)){ echo $beer_quantity_button; } ?>
</ul>
</div>
</div>
</div>
<!-- /page -->
I created a simple js banner.
First a company name will run into the center from left and then fading in an image logo
html
<div id="banner-container">
<div id="companyname"><p>P.Classique Trading Co. Ltd.</p></div>
<div id="logo"><img src="img/twitter_logo.png" width="100" height="100" /></div>
</div>
css
#banner-container {
position:relative;
left:300px;
top:100px;
overflow: hidden;
display:box;
background-color: #282800;
width:500px;
height:300px;
color:#FFFFFF;
}
#companyname {
position: relative;
color:yellow;
top:15px;
left:-500px;
font-family: 'Finger Paint', cursive;
}
#logo {
position: relative;
display:none;
top:50px;
left:200px;
}
js
$(document).ready(function() {
var left = $('#companyname').offset().left;
$("#companyname").css({left:left}).animate({"left":"120px"}, {duration:1000, easing:'easeOutBounce'});
$("#logo").fadeIn(1500);
}
);
the result is two animations start at the same time which is not I want to.
Working jsFiddle Demo
Use a callback for your animation:
$("#companyname")
.css({left:left})
.animate(
{"left":"120px"},
{
duration:1000,
easing:'easeOutBounce',
complete: function () {
$("#logo").fadeIn(1500);
}
}
);
Try this fiddle: http://jsfiddle.net/KhsWt/
You can use the second fadein as parameter for when first one finishes
$(document).ready(function() {
var left = $('#companyname').offset().left;
$("#companyname").css({left:left}).animate({left:"120px"}, 1000, 'easeOutBounce',
function() {
$("#logo").fadeIn(1500);
}
)});
I am looking to apply a jquery ui like highlight effect to an element , but I am using jquery mobile. Is there anything built into jquery mobile that would allow me to do that, without referencing any of the jquery ui stuff ?
Thanks
Would something like this work?
NOTE: this might affect the hash navigation but it's all CSS
http://jsfiddle.net/MEzAU/
CSS
:target {
-webkit-animation: target-fade 3s 1;
-moz-animation: target-fade 3s 1;
}
#-webkit-keyframes target-fade {
0% { background-color: rgba(0,0,0,.1); }
100% { background-color: rgba(0,0,0,0); }
}
#-moz-keyframes target-fade {
0% { background-color: rgba(0,0,0,.1); }
100% { background-color: rgba(0,0,0,0); }
}
HTML
Link 1
Link 2
Link 3
<p id="1">Paragraph 1</p>
<p id="2">Paragraph 2</p>
<p id="3">Paragraph 3</p>
Link reference:
http://snook.ca/archives/html_and_css/yellow-fade-technique-css-animations
You could also try this yellow fade technique solution: http://jsfiddle.net/xb8Km/
Its a nice solution because you don't have to use :target, which is built for anchors hrefs that could interfere with jQuery Mobile ajax hrefs; it also doesn't need the .effect function from jQuery UI which is not designed for jQuery mobile.
<div class="yft">
<div class="content">This is some content</div>
<div class="yft_fade"> </div>
</div>
<script>
$(document).ready(function() {
$(".yft").click(function() {
$(this).find(".yft_fade").show().fadeOut();
});
});
</script>
<style>
.yft_fade {
background-color:yellow;
display:none;
}
.content {
position:absolute;
top:0px;
}
</style>