Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,038

HOME > Client Script Forum > ต้องการซูมภาพในแกลลอรี่ สไลด์โชว์ครับ ช่วยแนะนำการเขียน jquery ด้วยครับ


[PHP] ต้องการซูมภาพในแกลลอรี่ สไลด์โชว์ครับ ช่วยแนะนำการเขียน jquery ด้วยครับ

 
Topic : 072731

Guest



คือผมจะใช้ แกลลอรี่ตัวนึง ซึ่งมันไม่มีการซูมภาพ ผมต้องการที่จะให้ภาพใหญ่สามารถซูมได้ด้วยครับ

ตัวนี้โคด html ครับ
Example.html
Code (PHP)
01.<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
03.<head>
04.<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
05.<title>Elegant Photo Gallery</title>
06.<link href="flickrGallery-large.css" type="text/css" rel="stylesheet" />
07.<script type="text/javascript" src="jquery-1.2.6.min.js"></script>
08.<script type="text/javascript" src="jquery-ui-personalized-1.6rc2.min.js"></script>
09.<script type="text/javascript" src="jquery.flickr-1.0.js"></script>
10.<script type="text/javascript" src="jquery.flickrGallery-1.0.2.js"></script>
11.<script type="text/javascript" src="jquery.panzoom.js"></script>
12.<script type="text/javascript">
13.$().ready(function(){
14.    $('#Gallery').flickrGallery({
15.        galleryHeight: 450
16. 
17.    });
18.});
19.</script>
20.<style>
21.#largeImageWrap { background:url(ajax-loader.gif) center 65px no-repeat; }
22.</style>
23.</head>
24.<body>
25.<div id="Gallery">
26.    <ul id="thumbs_1" class="thumbs">
27.        <li><img src="images/image_11.jpg" title="Desert Moon" width="300" /></li>
28.        <li><img src="images/image_16.jpg" title="Cat + Tree" width="500" /></li>
29.        <li><img src="images/image_10.jpg" title="Matisyahu - Hasidic Rap Reggae Superstar" width="400" /></li>
30.        <li><img src="images/image_15.jpg" title="Weirdo" width="650" /></li>
31.        <li><img src="images/image_13.jpg" title="Astronomy Picture of the Day" width="600" /></li>
32.         
33.    </ul>
34.</div>
35.</body>
36.</html>


jquery.flickr-1.0.js
Code (JavaScript)
001./*
002. * jQuery Flickr - jQuery plug-in
003. * Version 1.0, Released 2008.04.17
004. *
005. * Copyright (c) 2008 Daniel MacDonald (www.projectatomic.com)
006. * Dual licensed GPL http://www.gnu.org/licenses/gpl.html
008. */
009.(function($) {
010.$.fn.flickr = function(o){
011.var s = {
012.    api_key: null,              // [string]    required, see http://www.flickr.com/services/api/misc.api_keys.html
013.    type: null,                 // [string]    allowed values: 'photoset', 'search', default: 'flickr.photos.getRecent'
014.    photoset_id: null,          // [string]    required, for type=='photoset' 
015.    text: null,                     // [string]    for type=='search' free text search
016.    user_id: null,              // [string]    for type=='search' search by user id
017.    group_id: null,             // [string]    for type=='search' search by group id
018.    tags: null,                 // [string]    for type=='search' comma separated list
019.    tag_mode: 'any',            // [string]    for type=='search' allowed values: 'any' (OR), 'all' (AND)
020.    sort: 'relevance',    // [string]    for type=='search' allowed values: 'date-posted-asc', 'date-posted-desc', 'date-taken-asc', 'date-taken-desc', 'interestingness-desc', 'interestingness-asc', 'relevance'
021.    thumb_size: 's',            // [string]    allowed values: 's' (75x75), 't' (100x?), 'm' (240x?)
022.    size: null,                 // [string]    allowed values: 'm' (240x?), 'b' (1024x?), 'o' (original), default: (500x?)
023.    per_page: 100,              // [integer]   allowed values: max of 500
024.    page: 1,                      // [integer]   see paging notes
025.    attr: '',                   // [string]    optional, attributes applied to thumbnail <a> tag
026.    api_url: null,              // [string]    optional, custom url that returns flickr JSON or JSON-P 'photos' or 'photoset'
027.    params: '',                 // [string]    optional, custom arguments, see http://www.flickr.com/services/api/flickr.photos.search.html
028.    api_callback: '?',          // [string]    optional, custom callback in flickr JSON-P response
029.    callback: null              // [function]  optional, callback function applied to entire <ul>
030. 
031.    // PAGING NOTES: jQuery Flickr plug-in does not provide paging functionality, but does provide hooks for a custom paging routine
032.    // within the <ul> created by the plug-in, there are two hidden <input> tags,
033.    // input:eq(0): current page, input:eq(1): total number of pages, input:eq(2): images per page, input:eq(3): total number of images
034.     
035.    // SEARCH NOTES: when setting type to 'search' at least one search parameter  must also be passed text, user_id, group_id, or tags
036.     
037.    // SIZE NOTES: photos must allow viewing original size for size 'o' to function, if not, default size is shown
038.  };
039.  if(o) $.extend(s, o);
040.  return this.each(function(){
041.    // create unordered list to contain flickr images
042.        var list = $('<ul>').appendTo(this);
043.    var url = $.flickr.format(s);
044.        $.getJSON(url, function(r){
045.      if (r.stat != "ok"){
046.        for (i in r){
047.            $('<li>').text(i+': '+ r[i]).appendTo(list);
048.        };
049.      } else {
050.        if (s.type == 'photoset') r.photos = r.photoset;
051.        // add hooks to access paging data
052.        list.append('<input type="hidden" value="'+r.photos.page+'" />');
053.        list.append('<input type="hidden" value="'+r.photos.pages+'" />');
054.        list.append('<input type="hidden" value="'+r.photos.perpage+'" />');
055.        list.append('<input type="hidden" value="'+r.photos.total+'" />');
056.        for (var i=0; i<r.photos.photo.length; i++){
057.          var photo = r.photos.photo[i];
058.          // format thumbnail url
059.          var t = 'http://farm'+photo['farm']+'.static.flickr.com/'+photo['server']+'/'+photo['id']+'_'+photo['secret']+'_'+s.thumb_size+'.jpg';
060.          //format image url
061.          var h = 'http://farm'+photo['farm']+'.static.flickr.com/'+photo['server']+'/'+photo['id']+'_';
062.          switch (s.size){
063.            case 'm':
064.              h += photo['secret'] + '_m.jpg';
065.              break;
066.            case 'b':
067.              h += photo['secret'] + '_b.jpg';
068.              break;
069.            case 'o':
070.              if (photo['originalsecret'] && photo['originalformat']) {
071.                h += photo['originalsecret'] + '_o.' + photo['originalformat'];
072.              } else {
073.                h += photo['secret'] + '_b.jpg';
074.              };
075.              break;
076.            default:
077.              h += photo['secret'] + '.jpg';
078.          };
079.          var flickrLink = 'http://www.flickr.com/photos/' + r.photoset.owner + '/' + photo['id'];
080.          //console.log(flickrLink);
081.          list.append('<li><a href="'+h+'" '+s.attr+' title="'+flickrLink+'"><img src="'+t+'" alt="'+photo['title']+'" /></a></li>');
082.        };
083.        if (s.callback) s.callback(list);
084.      };
085.        });
086.  });
087.};
088.// static function to format the flickr API url according to the plug-in settings
089.$.flickr = {
090.    format: function(s){
091.        if (s.url) return s.url;
092.        var url = 'http://api.flickr.com/services/rest/?format=json&;jsoncallback='+s.api_callback+'&api_key='+s.api_key;
093.        switch (s.type){
094.            case 'photoset':
095.                url += '&method=flickr.photosets.getPhotos&photoset_id=' + s.photoset_id;
096.                break;
097.            case 'search':
098.                url += '&method=flickr.photos.search&sort=' + s.sort;
099.                if (s.user_id) url += '&user_id=' + s.user_id;
100.                if (s.group_id) url += '&group_id=' + s.group_id;
101.                if (s.tags) url += '&tags=' + s.tags;
102.                if (s.tag_mode) url += '&tag_mode=' + s.tag_mode;
103.                if (s.text) url += '&text=' + s.text;
104.                break;
105.            default:
106.                url += '&method=flickr.photos.getRecent';
107.        };
108.        if (s.size == 'o') url += '&extras=original_format';
109.        url += '&per_page=' + s.per_page + '&page=' + s.page + s.params;
110.        return url;
111.    }
112.};
113.})(jQuery);


jquery.flickrGallery-1.0.2.js
Code (JavaScript)
001./*
002. * jQuery FlickrGallery - jQuery plug-in
003. * Version 1.0.1, Released
004. *
005. * Copyright (c) 2008 Steven Dugas
006. * This work is licensed under a Creative Commons Attribution 3.0 Unported License.
007. */
008.(function($) {
009.$.fn.flickrGallery = function(options) {
010. 
011.  var defaults = {
012.        galleryHeight : 'auto',             // either [string] 'auto' or [integer]. If [integer] gallery will have a strict height to that number.
013.        userFlickr : 'false',               // [string], 'true' or 'false'. Determines if gallery is local or flickr based.
014.        useFlickrLargeSize: 'false',        // [string], 'true' or 'false'. Determines whether gallery is Large or Small.
015.        flickrAPIKey: '',                   // [string], required for Flickr gallery.
016.        photosetID: '',                     // [string], required for Flickr gallery.
017.        per_page: 30,                       // [integer], amount of thumbnails per 'page'.
018.        useHoverIntent: 'false',            // [string], 'true' or 'false'. Uses HoverIntent plugin for better Hovers.
019.        useLightBox: 'false'                // [string], 'true' or 'false. Uses jQuery Lightbox plugin for Small Images
020.  };
021.  var options = $.extend(defaults, options);
022.    //options.galleryHeight = 'auto';
023.  return this.each(function() {
024.    obj = $(this);
025. 
026.    // Massive function to create the Image Gallery and register all event handlers. Must be a function to recreate gallery on Next/Prev Page.
027.    function makeGallery(){
028.         
029.        // Create Variables
030.        var flickrLargeImg;
031.        var theCaption;
032.        var container;
033.        var stepCount;
034.        var count = 1;
035.        var totalImageCount = 0;
036.        var currentImageCount = 1; 
037.        thumbs = obj.find('ul');
038.        thumbs.addClass('galleryUL');
039.         
040.        // If useFlickr is true, create Flickr-only buttons.
041.        if ( options.useFlickr == 'true' ) {
042.            obj.prepend('<div class="largeImageWrap"><div class="largeImage_nextPage"></div><div class="largeImage_prevPage"></div><a href="" class="largeImage_flickrLink" target="_blank"><span>Flickr</span></a><div class="largeImage_prev"><span>Prev</span></div><div class="largeImage_next"><span>Next</span></div><div class="largeImage"></div><div class="caption"></div></div>');
043.        } else {
044.            obj.prepend('<div class="largeImageWrap"><div class="largeImage_prev"><span>Prev</span></div><div class="largeImage_next"><span>Next</span></div><div class="largeImage"></div><div class="caption"></div></div>');
045.        };
046.         
047.        var largeImageWrap = obj.find('.largeImageWrap');
048.        var nextPage = obj.find('.largeImage_nextPage');
049.        var prevPage = obj.find('.largeImage_prevPage');
050.        var nextImg = obj.find('.largeImage_next');
051.        var prevImg = obj.find('.largeImage_prev');
052.        var largeImageFlickrLink = obj.find('.largeImage_flickrLink');
053.        var largeImage = obj.find('.largeImage');
054.        var imgCaption = obj.find('.caption');
055. 
056.         
057.         
058.        // Determine if gallery is fixed or auto height. If Fixed, set height.
059.        if ( options.galleryHeight != 'auto' ) {
060.            var theHeight = parseFloat(options.galleryHeight);
061.            largeImageWrap.animate({ height: theHeight+'px' }, 600) ;
062.        }
063.         
064.        // If Flickr Gallery is on, disable links in Thumbnails.
065.        if ( options.useFlickr == 'true' ) {
066.            thumbs.children().click(function(){
067.                return false;
068.            });
069.        };
070.     
071.        // Add unique IDs to each thumbnail image
072. 
073.        thumbs.wrap('<div class="sliderGallery"></div>');      
074.        var sliderGallery = obj.find('.sliderGallery');
075.        sliderGallery.wrap('<div class="sliderGallery_Wrap"></div>');
076.        var sliderGalleryWrap = obj.find('.sliderGallery_Wrap');
077.        sliderGallery.append('<div class="slider"><div class="handle"></div></div>');
078.        var theSlider = obj.find('.slider');
079.        var theHandle = obj.find('.handle');
080.        count = 1;
081.        totalImageCount = 0;
082.        currentImageCount = 1;
083.        obj.find('.galleryUL img').each(function(){
084.            var IESRC = $(this).attr('src');
085.            $(this).attr('src',IESRC);
086.            $(this).attr('id','galleryThumb_'+count);
087.            count++;
088.            totalImageCount++;
089.        });
090. 
091.        // Function for clicking Next Page. This is a Flickr-only function.
092.        nextPage.click(function(){
093.            currentPage = parseFloat($(obj).find('input:eq(0)').val());
094.            totalPages = parseFloat($(obj).find('input:eq(1)').val());
095.            nextPage = currentPage + 1;
096.            if ( nextPage > totalPages ) {
097.                nextPage = 1;
098.            };
099.            $(theSlider, container).slider("destroy");
100.            sliderGalleryWrap.hide();
101.            $(obj).children().slideUp();
102.            obj.slideUp('slow',function(){
103.                obj.empty();
104.                obj.flickr({    
105.                    api_key: options.flickrAPIKey,    
106.                    type: 'photoset',
107.                    photoset_id: options.photosetID,
108.                    thumb_size: 'm',
109.                    per_page: options.per_page,
110.                    page: nextPage,
111.                    callback: function(){
112.                        makeGallery();
113.                    }
114.                });
115.                obj.slideDown();
116.            });
117.        });
118.         
119.        // Function for clicking Previous Page. This is a Flickr function.
120.        prevPage.click(function(){
121.            currentPage = parseFloat($(obj).find('input:eq(0)').val());
122.            totalPages = parseFloat($(obj).find('input:eq(1)').val());
123.            prevPage = currentPage - 1;
124.            if ( prevPage == 0 ) {
125.                prevPage = totalPages;
126.            };
127.            $(theSlider, container).slider("destroy");
128.            sliderGalleryWrap.hide();
129.            $(obj).children().slideUp();
130.            obj.slideUp('slow',function(){
131.                obj.empty();
132.                obj.flickr({    
133.                    api_key: options.flickrAPIKey,    
134.                    type: 'photoset',
135.                    photoset_id: options.photosetID,
136.                    thumb_size: 'm',
137.                    per_page: options.per_page,
138.                    page: prevPage,
139.                    callback: function(){
140.                        makeGallery();
141.                    }
142.                });
143.                obj.slideDown();
144.            });
145.        });
146.         
147.        // calcHeight function, used to process image changing on next, prev or click.
148. 
149.        function calcHeight() {            
150.            largeImage.fadeOut(function(){
151.                function doHeight(){
152.                    largeImage.fadeIn(function(){
153.                        var imgHeight = largeImage.find('img').height();
154.                        var captionHeight = imgCaption.height();
155.                        largeImage.find('img').css({
156.                            position: '',
157.                            visibility: 'visible',
158.                            display: 'none'
159.                        });
160.                        if ( options.galleryHeight == 'auto' ) {
161.                            largeImageWrap.animate({
162.                                height: imgHeight+captionHeight+'px'
163.                            }, function(){ largeImage.find('img').fadeIn(); imgCaption.fadeIn(); });
164.                        } else {
165.                            largeImage.find('img').fadeIn();
166.                            imgCaption.fadeIn();
167.                        };
168.                         
169.                    });
170.                    slideValue = currentImageCount-1;
171.                    slideValue = slideValue * stepCount;
172.                    $(theSlider, container).slider("moveTo",slideValue);
173.                };
174.                $(this).find('img').remove();
175.                imgCaption.empty();
176.                var i = new Image();
177.                if ( options.useFlickr == 'true' ) {
178.                     if ( options.useFlickrLargeSize == 'true') {
179.                        flickrLargeImg = thumbs.find('#galleryThumb_'+currentImageCount).parent().attr('href');
180.                        flickrLink = thumbs.find('#galleryThumb_'+currentImageCount).parent().attr('title')
181.                        theCaption = thumbs.find('#galleryThumb_'+currentImageCount).attr('alt');
182.                        i.onload = doHeight;
183.                        i.src = flickrLargeImg;
184.                        largeImage.append(i);
185.                     } else {
186.                        flickrLink = thumbs.find('#galleryThumb_'+currentImageCount).parent().attr('title');
187.                        theCaption = thumbs.find('#galleryThumb_'+currentImageCount).attr('alt');
188.                        i.onload = doHeight;
189.                        i.src = thumbs.find('#galleryThumb_'+currentImageCount).attr('src');
190.                        largeImage.append(i);
191.                        flickrLargeImg = thumbs.find('#galleryThumb_'+currentImageCount).parent().attr('href');
192.                        if ( options.useLightBox == 'true') {
193.                            largeImage.find('img').wrap('<a href="'+flickrLargeImg+'" title="'+theCaption+'"></a>');
194.                            largeImage.find('a').lightBox();
195.                        };
196.                     }
197.                    largeImageFlickrLink.attr('href',flickrLink);
198.                    largeImage.find('img').addClass(''+currentImageCount+'');
199.                } else {
200.                    thumbs.find('#galleryThumb_'+currentImageCount).clone().css('opacity',1).appendTo(largeImage);
201.                    theCaption = thumbs.find('#galleryThumb_'+currentImageCount).attr('title');
202.                    doHeight();
203.                }; 
204.                imgCaption.append(theCaption).hide();
205.                largeImage.find('img').css({
206.                    position: 'absolute',
207.                    visibility: 'hidden',
208.                    display: 'block'
209.                }).addClass(''+currentImageCount+'').attr('title',theCaption);
210.            });
211.        };
212.         
213. 
214. 
215.        // Create the slider
216.        obj.find('div.sliderGallery').each(function(){
217.            container = $(this);
218.            var ul = thumbs;
219.            var itemsWidth = ul.innerWidth() - container.outerWidth(); 
220.            var totalCount = totalImageCount;
221.            totalCount = parseFloat(totalCount-1);
222.            stepCount = itemsWidth/totalCount;
223.            var division = itemsWidth / totalCount;
224.            var theValue = 0;
225.            $(theSlider, container).slider({
226.                min: 0,
227.                max: itemsWidth,
228.                handle: theHandle,
229.                steps:totalCount,
230.                stop: function (event, ui) {
231.                    ul.animate({'left' : ui.value * -1}, 500);
232.                    theValue = ui.value;
233.                },
234.                slide: function (event, ui) {
235.                    ul.css('left', ui.value * -1);
236.                }
237.            });
238.            obj.find('.galleryUL img').click(function(){
239.                var clickThumb = $(this);
240.                var startCount = 0;
241.                var theCaption = $(this).attr('title');
242.                currentImageCount = $(this).attr('id');
243.                currentImageCount = parseFloat(currentImageCount.split("_",2)[1]);
244.                calcHeight();
245.            });
246.        });
247.        // End of SlideBar
248.     
249. 
250.        //  Fade in the first image with caption
251.        function startHeight() {   
252.            imgCaption.append(theCaption).hide();
253.            largeImage.find('img').css({
254.                position: '',
255.                visibility: 'visible',
256.                display: 'none'
257.            });
258.            largeImage.find('img').addClass(''+currentImageCount+'').attr('title',theCaption);
259.            largeImage.show(function(){
260.                imgHeight = largeImage.find('img').height();
261.                captionHeight = imgCaption.height();
262.                if ( options.galleryHeight == 'auto' ) {
263.                    largeImageWrap.animate({
264.                        height: imgHeight+captionHeight+'px'
265.                    },'slow','swing',
266.                    function(){    
267.                        largeImage.css({ visibility: 'visible' });
268.                        imgCaption.fadeIn();
269.                        largeImage.find('img').fadeIn(300, function(){
270.                            sliderGallery.hide().wrapInner('<div id="sliderGalleryInnerWrap"></div>');
271.                            var sliderGalleryInnerWrap = obj.find('#sliderGalleryInnerWrap');
272.                            sliderGalleryInnerWrap.hide();
273.                            sliderGalleryWrap.show();
274.                            sliderGallery.slideDown('slow', function(){
275.                            sliderGalleryInnerWrap.fadeIn();
276.                            });
277.                        });
278.                    });
279.                } else {
280.                    largeImage.css({ visibility: 'visible' });
281.                    largeImage.find('img').fadeIn('slow', function(){
282.                            sliderGallery.hide().wrapInner('<div id="sliderGalleryInnerWrap"></div>');
283.                            var sliderGalleryInnerWrap = obj.find('#sliderGalleryInnerWrap');
284.                            sliderGalleryInnerWrap.hide();
285.                            sliderGalleryWrap.show();
286.                            sliderGallery.slideDown('slow', function(){
287.                                sliderGalleryInnerWrap.fadeIn('slow');
288.                            });
289.                        }); 
290.                    imgCaption.fadeIn('slow');
291.                };
292.            });
293.        };
294.        sliderGalleryWrap.hide();
295.        largeImage.hide().css({visibility: 'hidden'});
296.        var i = new Image();
297.        if ( options.useFlickr == 'true' ) {
298.             if ( options.useFlickrLargeSize == 'true') {
299.                flickrLargeImg = thumbs.find('#galleryThumb_'+currentImageCount).parent().attr('href');
300.                flickrLink = thumbs.find('#galleryThumb_'+currentImageCount).parent().attr('title')
301.                theCaption = thumbs.find('#galleryThumb_'+currentImageCount).attr('alt');
302.                i.onload = startHeight;
303.                i.src = flickrLargeImg;
304.                largeImage.append(i);
305.             } else {
306.                flickrLargeImg = thumbs.find('#galleryThumb_'+currentImageCount).parent().attr('href');
307.                flickrLink = thumbs.find('#galleryThumb_'+currentImageCount).parent().attr('title')
308.                thumbs.find('#galleryThumb_'+currentImageCount).clone().appendTo(largeImage);
309.                theCaption = thumbs.find('#galleryThumb_'+currentImageCount).attr('alt');
310.                if ( options.useLightBox == 'true') {
311.                    largeImage.find('img').wrap('<a href="'+flickrLargeImg+'" title="'+theCaption+'"></a>');
312.                    largeImage.find('a').lightBox();
313.                }
314.                startHeight();
315.             }
316.            largeImageFlickrLink.attr('href',flickrLink);
317.            largeImage.find('img').addClass(''+currentImageCount+'');
318.        } else {
319.            thumbs.find('#galleryThumb_'+currentImageCount).clone().appendTo(largeImage);
320.            theCaption = thumbs.find('#galleryThumb_'+currentImageCount).attr('title');
321.            startHeight();
322.        };                         
323.        // Function to fadeIn or fadeOut Next/Prev buttons on hover.
324.        if ( options.useHoverIntent == 'false' ) {
325.            largeImageWrap.hover(function(){
326.                prevImg.fadeIn();
327.                nextImg.fadeIn();
328.                largeImageFlickrLink.fadeIn();
329.                nextPage.fadeIn();
330.                prevPage.fadeIn();
331.            },function(){
332.                obj.find('.largeImage_prev').fadeOut();
333.                obj.find('.largeImage_next').fadeOut();
334.                obj.find('.largeImage_flickrLink').fadeOut();
335.                obj.find('.largeImage_prevPage').fadeOut();
336.                obj.find('.largeImage_nextPage').fadeOut();
337.            });
338.            $(thumbs).children().find('img').hover(function(){
339.                $(this).animate({ opacity: 1 }, 300);
340.            },function(){
341.                $(this).animate({ opacity: .7 }, 300);     
342.            });
343.        } else {
344.            function hoverOn() {
345.                prevImg.fadeIn();
346.                nextImg.fadeIn();
347.                largeImageFlickrLink.fadeIn();
348.                nextPage.fadeIn();
349.                prevPage.fadeIn(); 
350.            };
351.            function hoverOff() {
352.                obj.find('.largeImage_prev').fadeOut();
353.                obj.find('.largeImage_next').fadeOut();
354.                obj.find('.largeImage_flickrLink').fadeOut();
355.                obj.find('.largeImage_prevPage').fadeOut();
356.                obj.find('.largeImage_nextPage').fadeOut();
357.            };
358.            var config = {   
359.                 sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)   
360.                 interval: 50, // number = milliseconds for onMouseOver polling interval   
361.                 over: hoverOn, // function = onMouseOver callback (REQUIRED)   
362.                 timeout: 200, // number = milliseconds delay before onMouseOut   
363.                 out: hoverOff // function = onMouseOut callback (REQUIRED)   
364.            };
365.            largeImageWrap.hoverIntent(config);
366.            function thumbHoverOn() {
367.                $(this).animate({ opacity: 1 }, 300);
368.            };
369.            function thumbHoverOff() {
370.                $(this).animate({ opacity: .7 }, 300);
371.            };
372.            var config2 = {   
373.                 sensitivity: 1, // number = sensitivity threshold (must be 1 or higher)   
374.                 interval: 25, // number = milliseconds for onMouseOver polling interval   
375.                 over: thumbHoverOn, // function = onMouseOver callback (REQUIRED)   
376.                 timeout: 50, // number = milliseconds delay before onMouseOut   
377.                 out: thumbHoverOff // function = onMouseOut callback (REQUIRED)   
378.            };
379.            $(thumbs).children().find('img').hoverIntent(config2);
380.        };
381.        // Change the opacity when hovering over thumbnails
382.        // Function for Previous button onclick
383.        prevImg.click(function(){
384.            var theSRC = largeImage.find('img').attr('src');
385.            currentImageCount = largeImage.find('img').attr('class');
386.            var newSRC = "";
387.            var newImage = "";
388.            var fixIE = "";
389.            var prevImageCount = currentImageCount - 1;
390.            if ( prevImageCount < 1 ) {
391.                currentImageCount = totalImageCount;
392.            } else {
393.             currentImageCount = prevImageCount;   
394.            };
395.            newSRC = thumbs.find('#galleryThumb_'+currentImageCount).attr('src');
396.            newImage = thumbs.find('#galleryThumb_'+currentImageCount).clone().css('opacity',1).addClass(''+currentImageCount+'');
397.            calcHeight();
398.        });
399.         
400.        // Function for Next button onclick
401.        nextImg.click(function(){
402.            var theSRC = largeImage.find('img').attr('src');
403.            currentImageCount = largeImage.find('img').attr('class');
404.            currentImageCount = parseFloat(currentImageCount);
405.            var newSRC = "";
406.            var theCaption = "";
407.            var newImage = "";
408.            var nextImageCount = currentImageCount + 1;
409.            if ( nextImageCount > totalImageCount ) {
410.                currentImageCount = 1;
411.            } else {
412.                currentImageCount = nextImageCount;
413.            };
414.            newSRC = thumbs.find('#galleryThumb_'+currentImageCount).attr('src');
415.            newImage = thumbs.find('#galleryThumb_'+currentImageCount).clone().css('opacity',1).addClass(''+currentImageCount+'');
416.            calcHeight();
417.        });
418.    };
419.     
420.    // Finally, if useFlickr is true, download images and create UL structure before creating Gallery. Else, just create Gallery.
421.    if ( options.useFlickr == 'true' ) {
422.        obj.flickr({    
423.            api_key: options.flickrAPIKey,    
424.            type: 'photoset',
425.            photoset_id: options.photosetID,
426.            thumb_size: 'm',
427.            per_page: options.per_page,
428.            page: 1,
429.            callback: function(){
430.                makeGallery();
431.            }
432.        });
433.    }else {
434.    makeGallery(); 
435.    };
436.  });
437. };
438.})(jQuery);


แล้วก็ตัว pan zoom ที่หามาครับ
Code (JavaScript)
001./**
002. * Pan/Zoom - it's just a quick hack, so don't expect too much
003. * @author Andrew Hedges, andrew@hedges.name
004. * @created 2009-12-27 12:27:09
005. * @license MIT
006. * @usage $.panzoom();
007. * @requires jQuery (tested with versions 1.3.2 and 1.4.0)
008. */
009. 
010.;
011.(function ($) {
012.    var css, titles;
013.     
014.    // CSS to apply to elements on init
015.    css = {
016.        a   : {
017.            'position' : 'relative',
018.            'overflow' : 'hidden',
019.            'display'  : 'inline-block',
020.            'width'    : undefined,
021.            'height'   : undefined
022.        },
023.        img : {
024.            'position' : 'absolute',
025.            'top'      : '0px',
026.            'left'     : '0px'
027.        }
028.    };
029.     
030.    // title text to display onhover
031.    titles = {
032.        small : 'Click to zoom in.',
033.        large : 'Click to zoom out.'
034.    };
035.     
036.    /**
037.     * Convert an x/y for one size to the x/y for another size
038.     * @private
039.     * @param array size1 [width, height]
040.     * @param array size2 [width, height]
041.     * @param array xy    [x, y]
042.     * @return array [x, y]
043.     */
044.    function proportions_(size1, size2, xy) {
045.        return [Math.round(xy[0] / (size1[0] / size2[0])), Math.round(xy[1] / (size1[1] / size2[1]))];
046.    }
047.     
048.    /**
049.     * Is the image in its "large" state?
050.     * @private
051.     * @param jQuery object a Anchor element
052.     * @param jQuery object img Image element
053.     * @return boolean
054.     */
055.    function isLarge_(a, img) {
056.        return (img.width() > a.width());
057.    }
058.     
059.    /**
060.     * Get the x and y of the click within the element
061.     * @private
062.     * @param jQuery object el Clicked element
063.     * @param object evt Event object
064.     * @return array [x, y]
065.     */
066.    function getPoint_(el, evt) {
067.        var offset;
068.        offset = $(el).offset();
069.        return [evt.pageX - offset.left, evt.pageY - offset.top];
070.    }
071.     
072.    /**
073.     * Get the pixel coordinates of the image based on the current mouse event
074.     * @private
075.     * @param jQuery object a Anchor element
076.     * @param jQuery object img Image element
077.     * @param Event object evt
078.     * @return void
079.     */
080.    function getCoords_(a, img, evt) {
081.        var pt, xy, top, left;
082.         
083.        pt = getPoint_(a, evt);
084.        xy = proportions_(img.dimensions.small, img.dimensions.large, pt);
085.         
086.        top  = (0 - (xy[1] - pt[1])) + 'px';
087.        left = (0 - (xy[0] - pt[0])) + 'px';
088.         
089.        return [left, top];
090.    }
091.     
092.    /**
093.     * Apply CSS, if not already applied
094.     * @private
095.     * @param jQuery object a   Anchor element
096.     * @param jQuery object img Image element
097.     * @return void
098.     */
099.    function applyCSS_(a, img) {
100.        // only apply the CSS if it hasn't already been applied
101.        if (true !== img.applied_) {
102.            css.a.width  = img.dimensions.small[0] + 'px';
103.            css.a.height = img.dimensions.small[1] + 'px';
104.             
105.            a.css(css.a);
106.            img.css(css.img);
107.             
108.            // store the fact that the styles have been applied
109.            img.applied_ = true;
110.        }
111.    }
112.     
113.    /**
114.     * Pan
115.     * @private
116.     * @param Event object evt
117.     * @return void
118.     */
119.    function move_(evt) {
120.        var a, img, coords;
121.         
122.        // get element references
123.        a   = evt.data.a;
124.        img = evt.data.img;
125.         
126.        // get new position
127.        coords = getCoords_(a, img, evt);
128.         
129.        // change position
130.        img.css({
131.            top  : coords[1],
132.            left : coords[0]
133.        });
134.         
135.        // disable browser's built-in behavior
136.        evt.preventDefault();
137.    }
138.     
139.    /**
140.     * Scale image to the larger size
141.     * @private
142.     * @param jQuery object a   Anchor element
143.     * @param jQuery object img Image element
144.     * @param Event object evt
145.     * @return void
146.     */
147.    function scaleUp_(a, img, evt) {
148.        var coords;
149.         
150.        coords   = getCoords_(a, img, evt);
151.         
152.        img.animate({
153.            top    : coords[1],
154.            left   : coords[0],
155.            width  : img.dimensions.large[0],
156.            height : img.dimensions.large[1]
157.        }, 'fast', function () {
158.            a
159.                .bind('mousemove', {a : a, img : img}, move_) // enable panning
160.                .attr('title', titles.large)
161.            ;
162.        });
163.         
164.        // swap source while it's enlargenating
165.        img.attr('src', img.srcs.large);
166.    }
167.     
168.    /**
169.     * Scale image back to original size
170.     * @private
171.     * @param jQuery object a   Anchor element
172.     * @param jQuery object img Image element
173.     * @return void
174.     */
175.    function scaleDown_(a, img) {
176.        img.animate({
177.            top    : '0px',
178.            left   : '0px',
179.            width  : img.dimensions.small[0],
180.            height : img.dimensions.small[1]
181.        }, 'fast', function () {
182.            a
183.                .unbind('mousemove', move_) // disable panning
184.                .attr('title', titles.small)
185.            ;
186.             
187.            // swap source after it's done scaling down
188.            img.attr('src', img.srcs.small);
189.        });
190.    }
191.     
192.    /**
193.     * Initialize
194.     * @public
195.     * @param string selector CSS selector for the container for the image(s) (optional, defaults to ".panzoom a")
196.     * @return void
197.     */
198.    function panzoom(selector) {
199.        selector = selector || '.panzoom a';
200.         
201.        // act on each anchor element
202.        $.each($(selector), function (i, val) {
203.            var a, img, lrg;
204.             
205.            a   = $(this);
206.            img = $('img', a);
207.             
208.            // preload large image
209.            lrg = new Image();
210.             
211.            // enable click event once large image has loaded
212.            lrg.onload = function (evt) {
213.                img.srcs = {
214.                    small : img.attr('src'),
215.                    large : this.src
216.                };
217.                 
218.                img.dimensions = {
219.                    small : [img.width(), img.height()],
220.                    large : [lrg.width, lrg.height]
221.                };
222.                 
223.                a
224.                    .click(function (evt) {
225.                        applyCSS_(a, img);
226.                         
227.                        if (isLarge_(a, img)) {
228.                            scaleDown_(a, img);
229.                        }
230.                        else {
231.                            scaleUp_(a, img, evt);
232.                        }
233.                         
234.                        evt.preventDefault();
235.                    })
236.                    .attr('title', titles.small)
237.                ;
238.            };
239.             
240.            // start loading large image
241.            lrg.src = a[0].href;
242.        });
243.    }
244.     
245.    // expose public method
246.    $.extend({
247.        panzoom : panzoom
248.    });
249.})(jQuery);


อันนี้เดโม่ตัวแพนซูมครับ
http://dynamicdrive.com/dynamicindex4/imagepanner.htm
อันนี้ตัวสไลด์โชว์ครับ
http://www.userfriendlythinking.com/Blog/BlogDetail.asp?p1=7013&p2=101&p7=3001



Tag : jQuery

Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2012-01-26 22:09:27 By : kids View : 1921 Reply : 1
 

 

No. 1



โพสกระทู้ ( 74,059 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

code เยอะน่ะครับ ลองดูตัวนี้ครับ



Go to : ikikkok Banner Slide jQuery Plug-In 0.1 Beta
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-01-27 10:57:49 By : webmaster
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ต้องการซูมภาพในแกลลอรี่ สไลด์โชว์ครับ ช่วยแนะนำการเขียน jquery ด้วยครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)





ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2025 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่