1// initialise as usual 2var gallery = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, items, options);
3 4// create variable that will store real size of viewport 5var realViewportWidth,
6 useLargeImages = false,
7 firstResize = true,
8 imageSrcWillChange;
910// beforeResize event fires each time size of gallery viewport updates11 gallery.listen('beforeResize', function() {
12// gallery.viewportSize.x - width of PhotoSwipe viewport13// gallery.viewportSize.y - height of PhotoSwipe viewport14// window.devicePixelRatio - ratio between physical pixels and device independent pixels (Number)15// 1 (regular display), 2 (@2x, retina) ...161718// calculate real pixels when size changes19 realViewportWidth = gallery.viewportSize.x * window.devicePixelRatio;
2021// Code below is needed if you want image to switch dynamically on window.resize2223// Find out if current images need to be changed24if(useLargeImages && realViewportWidth < 1000) {
25 useLargeImages = false;
26 imageSrcWillChange = true;
27 } elseif(!useLargeImages && realViewportWidth >= 1000) {
28 useLargeImages = true;
29 imageSrcWillChange = true;
30 }
3132// Invalidate items only when source is changed and when it's not the first update33if(imageSrcWillChange && !firstResize) {
34// invalidateCurrItems sets a flag on slides that are in DOM,35// which will force update of content (image) on window.resize.36 gallery.invalidateCurrItems();
37 }
3839if(firstResize) {
40 firstResize = false;
41 }
4243 imageSrcWillChange = false;
4445});
464748// gettingData event fires each time PhotoSwipe retrieves image source & size49 gallery.listen('gettingData', function(index, item) {
5051// Set image source & size based on real viewport width52if( useLargeImages ) {
53 item.src = item.originalImage.src;
54 item.w = item.originalImage.w;
55 item.h = item.originalImage.h;
56 } else {
57 item.src = item.mediumImage.src;
58 item.w = item.mediumImage.w;
59 item.h = item.mediumImage.h;
60 }
6162// It doesn't really matter what will you do here, 63// as long as item.src, item.w and item.h have valid values.64//65// Just avoid http requests in this listener, as it fires quite often6667});
686970// Note that init() method is called after gettingData event is bound71 gallery.init();
网上关于SQL优化的教程很多,但是比较杂乱。近日有空整理了一下,写出来跟大家分享一下,其中有错误和不足的地方,还请大家纠正补充。
这篇文章我花费了大量的时间查找资料、修改、排版,希望大家阅读之后,感觉好的话推荐给更多的人,让更多的人看到、纠正以及补充。
1.对查询进行优化,要尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引。
2.应尽量避免在 where
Zookeeper类是Zookeeper提供给用户访问Zookeeper service的主要API,它包含了如下几个内部类
首先分析它的内部类,从WatchRegistration开始,为指定的znode path注册一个Watcher,
/**
* Register a watcher for a particular p
何为部分应用函数?
Partially applied function: A function that’s used in an expression and that misses some of its arguments.For instance, if function f has type Int => Int => Int, then f and f(1) are p