I'm testing a chart made with d3.js. This graph zooms in by scrolling on it.
I would like with cypress to trigger the zoom with the scroll, I have made these attempts but nothing happens.
cy.get('.pippo > svg')
.trigger('wheel', 500, 500, { force: true });
cy.get('.pippo > svg')
.trigger('wheel', { x: 500, y: 500, force: true });
Related
trying to build a website with swiper with bigger number of photos.
On various browsers on Mac and PC it works well, but fail on ios safari after more than 50 images are within my images array.
Failure is that IOS Safari try to load the page, refreshes automatically and try again and again, then show a message saying that website loading failed.
Same on IOS Firefox works.
The source I build up using some PHP within a CMS (LEPTON), after collection the image names (without size & extension) within an array:
foreach( $aImages as $image )
{
$div .= ' <div class="swiper-slide" data-title="' . $image . '" >' . PHP_EOL;
$div .= ' <img data-src="' . $imageURL . $image . '_8b.png" data-srcset="' . $imageURL . $image . '_24b.png 1200w" class="swiper-lazy">' . PHP_EOL;
$div .= ' <div class="swiper-lazy-preloader"></div>' . PHP_EOL;
$div .= ' </div>' . PHP_EOL;
}
my JS to initialize the slider looks like:
$(document).ready(function () {
//initialize swiper when document ready
var mySwiper = new Swiper ('.swiper-container', {
/* parameters with different value than default */
// Duration of transition between slides (in ms)
speed: 1400,
// fading effect
effect: 'fade',
fadeEffect: {
crossFade: true
},
// show hand on image
grabCursor: true,
// add visibility class to currently showing image
watchSlidesProgress: true,
watchSlidesVisibility: true,
// Lazy Loading
preloadImages: false,
lazy: {
loadPrevNext: true,
loadPrevNextAmount: 1,
loadOnTransitionStart: true,
},
// continuous loop mode
loop: true,
// double click zoom into image
zoom: false,
// enable keyboard navigation prev/next
keyboard: {
enabled: true,
onlyInViewport: true,
pageUpDown: true,
},
// Navigation arrows
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
hideOnClick: false,
},
// center image
centeredSlides: true,
centeredSlidesBounds: false,
// autoplay
autoplay: {
delay: 3000,
disableOnInteraction: true
},
autoplay: false,
});
Any idea what's wrong or what I can change in order to solve my issue ?
Thx in advance
I think the solution for my problem are the virtual slides ....
Testing this but getting other issues there ....
And the available examples in native JS does not really help.
Update: Finally I got it running with virtual slides.
However there is a bug within combination with fadings.
Without fade parameter it is running.
I am using Swiper 3.4.2 slider with thumbs as a pagination slider. And I need to disable drag on the pagination slider but to enable click events so the main slider can be changed by clicking on thumbs in the pagination slider.
var galleryThumbs = new Swiper('.gallery-thumbs', {
spaceBetween: 0,
slidesPerView: 'auto',
shortSwipes: false,
slideToClickedSlide: true,
preventClicksPropagation: false,
preventClicks: false
});
By setting simulateTouch to false, I am loosing the click touch event also.
Setting the touchRatio: 0 will disable the drag touch event and leave the click touch event enabled
Update from v4
allowTouchMove: false,
From version 4.0, you can use:
allowTouchMove
If false, then the only way to switch the slide is use of external API
functions like slidePrev or slideNext
You can alsow use touchRatio at breakpoints:
breakpoints: {
600: {
slidesPerView: 1,
spaceBetweenSlides: 30,
touchRatio: 1
},
768: {
slidesPerView: 2,
touchRatio: 0
}
},
I am using CasperJS 1.1.0 with PhantomJs 2.0. I am using Linux server.
I have a script, trying to run and take screenshots.
This screenshot is fine for local server nor for live.
Screenshot of the site will look like this:
https://i.stack.imgur.com/dJe4L.png
So, instead of the actual letters, it renders square boxes.
var casper = require('casper').create({
verbose: true,
});
casper.options.waitTimeout = 40000;
casper.options.viewportSize = {width: 1200, height: 768};
phantom.cookiesEnabled = true;
casper.start('http://domain.com/', function() {
this.wait(5000, function () {
this.echo(this.getTitle());
this.capture("screenshot.png");
});
});
casper.run(function () {
this.exit(0);
});
Please tell me where i am wrong.
I would use waitForSelector on the items that you're wanting screenshots of, rather than the 5 second hard wait. Consider adding
verbose: true
waitTimeout:20000
Which will give you 20 second wait limit, longer than the 5 seconds default. Then, instead of your current wait, use something like:
this.waitForSelector('img', function() {
this.capture('test.png')
}
You can change the img selector to be something more specific, but waiting for the images themselves to load is a pretty certain way of making sure they will be captured. The reason we changed the timeout to 20 seconds is in case their site takes a little longer to load their images :)
Let me know if this doesn't help, happy to follow up. I will need examples of the site and the image you'd like though.
EDIT: Can confirm this works for me, let me know if it works for you.
var casper = require('casper').create({
verbose: true,
logLevel: 'error',
pageSettings: {
loadImages: true,
loadPlugins: true,
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11'
},
clientScripts: ['vendor/jquery.min.js', 'vendor/lodash.js'],
viewportSize: {
width: 1600,
height:1000
},
});
casper.start('http://dev.bunkerbradleycouture.com/')
casper.then(function() {
this.waitForSelector('img', function() {
this.capture('test.png')
})
})
casper.run()
We are working on a mobile web application. The designer likes the image carousel effect on App Store (the screenshots of the an App). So we try to mimic the same effect using JavaScript.
We are using iScroll to implement. So here is a customization of its demo carousel: http://jsfiddle.net/0t9savgj/. The options are:
{
scrollX: true,
scrollY: false,
momentum: false,
snap: true,
snapSpeed: 400,
keyBindings: true,
indicators: {
el: document.getElementById('indicator'),
resize: false
}
});
The problem is: for the last image, there is always some extra space, which is unwanted:
Does any one knows how to solve this? Or some other JS libraries implementing the same carousel? Thanks.
After exploration, the only way is to use the scroll event of iscroll-probe.js. Manually stop the scrolling when reaching the right border. But the indicators are not exact.
I am trying to take a picture using camera in Sencha Touch 2. Here i have one button 'Take a Picture', when i will press it, camera should start. As i am new to this sencha touch 2, i am unable to figure it out, how to do this?
For this i used the below code:
Sencha Fiddle Link
Please help me. I do not want to use Phone gap.
You have to add device folder of Sencha Library in root directory
and add below code in
Ext.require('Ext.device.Camera');
and use this code for capture image using camera
Ext.device.Camera.capture({
success: function(image) {
imageView.setSrc(image);
},
quality: 75,
width: 200,
height: 200,
destination: 'data'
});
If you want to use purely sencha, then you can check this code:
xtype: 'button',
handler: function(button, event) {
Ext.device.Camera.capture({
source: 'camera',
destination: 'data',
success: function(imagedata) {
var img = Ext.getCmp('theimage');
img.setSrc('data:image/jpeg;base64,' +imagedata);
},
failure: function() {
Ext.Msg.alert('Error', 'There was an error when acquiring the picture.');
},
scope: this
});
But if you want to use phonegap camera features, may be you have to change the code. As sencha is giving the default feature to handle the camera, i wish not to go with phonegap. Hope it will help..