I have some problem in my program two slides are working automatically but I want two slides have two move same and also i don't want any delay beteween two slides
Please help me
Thanks for help
var mySwiper = new Swiper('#first-slider',{
loop:true,
grabCursor: true,
autoplay: 2500,
simulateTouch: false,
transitionSpeed: 1000,
var mySwiper1 = new Swiper('#second-slider',{
loop:true,
grabCursor: true,
autoplay: 2500,
simulateTouch: false,
transitionSpeed: 1000,
});
in this two sliders;
when it is moving i have some delay between thease two sliders
delay means first of all first slider is moving after that second slider is moving I don't want that
I want two slides have two move same path without any delay
So as a workaround, don't set both sliders on a timed interval.
Only set the first slider to autoplay.
Then in the onSlideChangeStart, trigger the second one to slide, like thins:
var mySwiper = new Swiper('#first-slider',{ loop:true, grabCursor:true,
autoplay: 2500, simulateTouch: false, transitionSpeed: 1000,
onSlideChangeStart: function(swiper, direction) {
mySwiper1.slideNext();
} });
var mySwiper1 = new Swiper('#second-slider',{ loop:true, grabCursor:
true, simulateTouch: false, transitionSpeed: 1000});
This way your swiper will just do its thing, but the second one depending on the first, so they will ALWAYS move together...
Use this snippet to try, and accept answer if it is what you wanted :)
var mySwiper = new Swiper('#first-slider',{ loop:true, grabCursor:true,
autoplay: 2500, simulateTouch: false, transitionSpeed: 1000,
// Navigation arrows
onSlideChangeStart: function(swiper, direction) {
if (typeof mySwiper1 != "undefined"){
mySwiper1.slideNext();
}else{
alert("PageLoad");
}
}
});
var mySwiper1 = new Swiper('#second-slider',{ loop:true, grabCursor:
true, simulateTouch: false, transitionSpeed: 1000});
.swiper-container {
width: 100px;
height: 100px;
}
<link href="http://cdnjs.cloudflare.com/ajax/libs/Swiper/3.0.6/css/swiper.min.css" rel="stylesheet"/>
<script src="http://cdnjs.cloudflare.com/ajax/libs/Swiper/3.0.6/js/swiper.jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/Swiper/3.0.6/js/swiper.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Slider main container -->
<div class="swiper-container" id='first-slider'>
<!-- Additional required wrapper -->
<div class="swiper-wrapper" >
<!-- Slides -->
<div class="swiper-slide" style="background-color:red">Slide 1</div>
<div class="swiper-slide" style="background-color:green">Slide 2</div>
<div class="swiper-slide" style="background-color:yellow">Slide 3</div>
</div>
</div>
<!-- Slider main container -->
<div class="swiper-container" id='second-slider'>
<div class="swiper-wrapper" >
<!-- Slides -->
<div class="swiper-slide" style="background-color:green">Slide 1</div>
<div class="swiper-slide" style="background-color:yellow">Slide 2</div>
<div class="swiper-slide" style="background-color:blue">Slide 3</div>
</div>
</div>
Also, for you to play around with:
http://jsfiddle.net/yuayL7zq/2/
Here is a fiddle i made, to try my ideas.
The problem is that I had two sliders with sliding time interval 2500. In this case, two sliders are working fine without any delay during fist time. After that if I open two or more new tabs in my browsers, and then go to my webpage. Now there is a delay between two sliders.
Below is the code I had used for slide function,
var mySwiper = new Swiper('#first-slider',{
loop:true,
grabCursor: true,
autoplay: 2500,
simulateTouch: false,
transitionSpeed: 1000,
onSlideChangeStart: function(swiper, direction) {// my task will go here...}
});
var mySwiper1 = new Swiper('#second-slider',{
loop:true,
grabCursor: true,
autoplay: 2500,
simulateTouch: false,
transitionSpeed: 1000,
});
I can sure that whenever I reload the page two sliders are working fine with same time interval. I had this problem whenever I moved to new tab and come back to my webpage.Is there any mistake in the two sliders that cause delay between sliders? -Thanks for help
Related
I am using GLightbox in a project I am working on. I have a hyperlink that has a URL to a self-hosted MP4 video. The video is opened in a GLightbox. I have poster images already setup for my videos, but I can't figure out where to set the poster image in the Glightbox setup. Here is my html link that launches the video in the lightbox.
<a href="<?= $video_url; ?>" class="standard-lightbox">
Here is the javascript configuration I have in my site.js file:
let standardLightboxSlideHTML = `<div class="gslide">
<div class="gslide-inner-content">
<div class="ginner-container">
<div class="gslide-media">
</div>
<div class="gslide-description">
<div class="gdesc-inner">
<h4 class="gslide-title"></h4>
<div class="gslide-desc"></div>
</div>
</div>
</div>
</div>
</div>`;
var standardLightbox = GLightbox({
selector: '.standard-lightbox',
width: '1280px',
height: '720px',
skin: 'modern',
closeOnOutsideClick: true,
slideHTML: standardLightboxSlideHTML,
type:'video',
autoplayVideos: false,
plyr: {
config: {
ratio: '16:9', // or '4:3'
muted: false,
hideControls: false,
autoplay: false,
autopause: true,
volume: 0.5,
controls: ['play-large', 'play','progress','volume','mute','fullscreen']
}
}
});
I have tried adding a data-poster value to the hyperlink. That didn't work. That is where I would like to set it and then I want to GLightbox to use it. Any ideas how to make that work?
I want to tag this post as "glightbox", but I don't have enough rep.
I was able to resolve my problem this way.
In wordpress I setup two new fields, one for the url to the video and another for the poster image.
I changed my code to output the url and poster urls in the hyperlink that is clicked.
In my Glightbox setup, I just grab those values and add it dynamically with javascript to the video tag. I also add a counter to the hyperlink so I can append the count value to create an ID selector for the video.
standardLightbox.on('slide_after_load', (data) => {
const { slideIndex, slideNode, slideConfig, player, trigger } = data;
var btnClicked = document.getElementById(trigger.id);
var posterimage = btnClicked.getAttribute('data-html5videoposter');
var videoid = btnClicked.getAttribute('data-videoid');
// use the index
var getVideoTag = document.getElementById(videoid);
getVideoTag.setAttribute('poster', posterimage);
});
I am using ScrollMagic plugin for parallax scrolling effect. Below is my code
HTML Code
<div style="position:fixed;right:50px;top:50px;width:200px;height:300px;background:#fff;z-index:1">
<div>ONE</div>
<div>TWO</div>
<div>THREE</div>
<div>FOUR</div>
</div>
<div id="pinContainer">
<div id="slideContainer">
<section class="panel blue">
<a id="one"></a>
<b>ONE</b>
</section>
<section class="panel turqoise">
<a id="two"></a>
<b>TWO</b>
</section>
<section class="panel green">
<a id="three"></a>
<b>THREE</b>
</section>
<section class="panel bordeaux">
<a id="four"></a>
<b>FOUR</b>
</section>
</div>
</div>
JAVASCRipt Code
$(function () { // wait for document ready
// init
var controller = new ScrollMagic.Controller();
// define movement of panels
var wipeAnimation = new TimelineMax()
// animate to second panel
.to("#slideContainer", 0.5, {z: -150}) // move back in 3D space
.to("#slideContainer", 1, {x: "-25%"}) // move in to first panel
.to("#slideContainer", 0.5, {z: 0}) // move back to origin in 3D space
// animate to third panel
.to("#slideContainer", 0.5, {z: -150, delay: 1})
.to("#slideContainer", 1, {x: "-50%"})
.to("#slideContainer", 0.5, {z: 0})
// animate to forth panel
.to("#slideContainer", 0.5, {z: -150, delay: 1})
.to("#slideContainer", 1, {x: "-75%"})
.to("#slideContainer", 0.5, {z: 0});
// create scene to pin and link animation
new ScrollMagic.Scene({
triggerElement: "#pinContainer",
triggerHook: "onLeave",
duration: "500%"
})
.setPin("#pinContainer")
.setTween(wipeAnimation)
.addIndicators() // add indicators (requires plugin)
.addTo(controller);
// change behaviour of controller to animate scroll instead of jump
controller.scrollTo(function (newpos) {
TweenMax.to(window, 0.5, {scrollTo: {y: newpos}});
});
// bind scroll to anchor links
$(document).on("click", "a[href^='#']", function (e) {
var id = $(this).attr("href");
if ($(id).length > 0) {
e.preventDefault();
// trigger scroll
controller.scrollTo(id);
// if supported by the browser we can even update the URL.
if (window.history && window.history.pushState) {
history.pushState("", document.title, id);
}
}
});
});
How to achieve the anchor scrolling functionality using scrollmagic plugin.
Using above code when I click on anchor link its not going to the particular section.
I had the same problem today.
Try to replace the "window" element with your "#pinContainer" element.
Change your code from:
controller.scrollTo(function (newpos) {
TweenMax.to(window, 0.5, {scrollTo: {y: newpos}});
});
to:
controller.scrollTo(function (newpos) {
TweenMax.to($('#pinContainer'), 0.5, {scrollTo: {y: newpos}});
});
Hope that helps.
I'm using two Cycle slideshows with a single pager and different effects on each slideshow (with the metadata plugin).
I would also like to animate the first slide of each slideshow as documented here, but I'm having trouble with the syntax.
This is my current js
$(document).ready(function() {
$('.slideshow').each(function(index) {
$(this).cycle({
pager: '#pager',
pagerAnchorBuilder: function(i) {
if (index == 0)
// for first slideshow, return a new anchro
return ''+(i+1)+'';
// for 2nd slideshow, select the anchor created previously
return '#pager a:eq('+i+')';
}
});
});
});
The effects are coded on the .slideshow divs (with the metadata plugin)
<div class="slideshow { fx: 'scrollRight', timeout: 0, cleartypeNoBg: true, speed: 750, easing: 'easeInOutBack' }">
<div class="slideshow { fx: 'scrollLeft', timeout: 0, cleartypeNoBg: true, speed: 750, easing: 'easeInOutBack' }">
I've been looking through the Fancybox API and the forums here with no luck so far.
Basically when the window is resized the embedded PDF in the fancybox resizes, but the fancybox container does not and bleeds off the right side of the browser.
Heres when it first opens: http://lizbmorrison.net/fancybox1.png
And when the window is resized: http://lizbmorrison.net/fancybox2.png
HTML:
<li class="pdf"><a class="fancypdf" href="#mydoc">View PDF</a></li>
<div id="mydoc" style="display:none;">
<embed class="embed" src="<?php echo wp_get_attachment_url( $PDF->ID ); ?>"></embed>
</div>
JS:
$(document).ready(function() {
var width = $(window).width() * 0.9;
var height = $(window).height() * 0.9;
$('.embed').css('width', width).css('height', height);
$('a.fancypdf').fancybox({
'type': 'inline',
'margin': 0,
'centerOnScroll': false,
'hideOnContentClick': false,
'autoDimensions': true,
'autoScale': true,
'transitionIn': 'fade',
'transitionOut': 'fade',
});
});
$(window).resize(function () {
var width = $(window).width() * 0.9;
var height = $(window).height() * 0.9;
$('.embed').css('width', width).css('height', height);
});
Any ideas?
This is what I've settled on, still not perfect though.
HTML:
<li class="pdf"><a class="fancypdf" style="padding-top: 20px;" href="<?php echo wp_get_attachment_url( $PDF->ID ); ?>">View PDF</a></li>
JS:
$('.fancypdf').fancybox({
'type': 'iframe',
'centerOnScroll': true,
'width': 800,
'height': 600,
'margin': 20,
'autoScale': false,
'autoDimensions': false
});
I have a page that I would like to use some sencha items on along with some non-sencha html.
So the page might be...(after loading sencha headers)
<div id="banner"><h1>#if (Model != null)
{#Model.DisplayName}</h1></div>
<div style="background-color: #CFE1E8; padding: 10px; border: 1px solid black; ">
<div id="buttonDiv"></div>
<script type="text/javascript" src="/Content/js/widgets/button.js"></script>
<div id="searchDiv"></div>
<script type="text/javascript" src="/Content/js/widgets/search.js"></script>
<div id="carouselDiv"></div>
<script type="text/javascript" src="/Content/js/widgets/carousel.js"></script>
<div id="panelDiv"></div>
<script type="text/javascript" src="/Content/js/widgets/panel.js"></script>
</div>
Each of the js files contains some sencha code to render the control into the associated div. For example:
Ext.setup({
fullscreen: false,
onReady: function () {
var panel = new Ext.Panel({
title: 'Message Title',
fullscreen: false,
renderTo: 'buttonDiv',
defaults: {
// applied to each contained item
width: 120
},
items: [
{
xtype: 'button',
text: 'Click Me',
handler: function () {
alert("You Clicked Me...");
}
}
]
});
}
});
The problem I'm having is that when the page is taller than the width of the phone, anytime I touch the screen, the page immediately jumps to the bottom of the page. The normal page scrolling doesn't work at all.
Any suggestions? Thanks.
Try assigning your components a layout and possibly a flex, e.g.:
layout: {
type: 'vbox',
align: 'stretch'
},
and
flex: 1
For scrolling, you could try:
scroll: 'vertical'
Also, another way of using HTML inside sencha is to use the html property in your components, e.g:
new Ext.Panel({
scroll: 'vertical',
layout: {
type: 'vbox',
align: 'stretch'
},
flex: 1
items: [{
html: 'HTML content inside a panel',
}]
});
I ended up doing two things:
Added an Ext.util.Scroller on the body. There's a bug with the Ext.util.Scroller on iPhones that it won't actually let you scroll upwards. Works fine on Androids though.
"Registered" the content of each module's js as a function by pushing to a global variable so that it would get added in the head and then executed them all in a loop, so I only ran Ext.Setup once.