차근차근/JQuery Ajax Jstl

반응형 웹 - 터치 슬라이드 이미지

예쁜꽃이피었으면 2014. 10. 20. 17:54



소개된 블로그

http://blog.daum.net/_blog/BlogTypeView.do?blogid=0dfbt&articleno=16&categoryId=11®dt=20140117191420

http://blog.daum.net/bo_m/16



데모 페이지

http://www.owlgraphic.com/owlcarousel/#demo



Demo

How To Use

1. Load jQuery and include Owl Carousel plugin files

To use Owl Carousel, you’ll need to make sure both the Owl and jQuery 1.7 or higher scripts are included.

  1. <!-- Important Owl stylesheet -->
  2. <link rel="stylesheet" href="owl-carousel/owl.carousel.css">
  3.  
  4. <!-- Default Theme -->
  5. <link rel="stylesheet" href="owl-carousel/owl.theme.css">
  6.  
  7. <!-- jQuery 1.7+ -->
  8. <script src="jquery-1.9.1.min.js"></script>
  9.  
  10. <!-- Include js plugin -->
  11. <script src="assets/owl-carousel/owl.carousel.js"></script>

2. Set up your HTML

You don't need any special markup. All you need is to wrap your divs(owl works with any type element) inside the container element <div class="owl-carousel">. Class "owl-carousel" is mandatory to apply proper styles that come from owl.carousel.css file.

  1. <div id="owl-example" class="owl-carousel">
  2. <div> Your Content </div>
  3. <div> Your Content </div>
  4. <div> Your Content </div>
  5. <div> Your Content </div>
  6. <div> Your Content </div>
  7. <div> Your Content </div>
  8. <div> Your Content </div>
  9. ...
  10. </div>

3. Call the plugin

Now call the Owl initializer function and your carousel is ready.

  1. $(document).ready(function() {
  2.  
  3. $("#owl-example").owlCarousel();
  4.  
  5. });

Customizing

1. Options

All of the options below are available to customize Owl Carousel.

VariableDefaultTypeDescription
items5intThis variable allows you to set the maximum amount of items displayed at a time with the widest browser width
itemsDesktop[1199,4]arrayThis allows you to preset the number of slides visible with a particular browser width. The format is [x,y] whereby x=browser width and y=number of slides displayed. For example [1199,4] means that if(window<=1199){ show 4 slides per page} Alternatively useitemsDesktop: false to override these settings. Check my Custom Demo
itemsDesktopSmall[979,3]arrayAs above.
itemsTablet[768,2]arrayAs above.
itemsTabletSmallfalsearrayAs above. Default value is disabled.
itemsMobile[479,1]arrayAs above
itemsCustomfalsearrayThis allow you to add custom variations of items depending from the width If this option is set, itemsDeskop, itemsDesktopSmall, itemsTablet, itemsMobile etc. are disabled For better preview, order the arrays by screen size, but it's not mandatory Don't forget to include the lowest available screen size, otherwise it will take the default one for screens lower than lowest available. 
Example:
[[0, 2], [400, 4], [700, 6], [1000, 8], [1200, 10], [1600, 16]]
For more information about structure of the internal arrays see itemsDesktop. Check myCustom Demo
singleItemfalsebooleanDisplay only one item. See demo
itemsScaleUpfalsebooleanOption to not stretch items when it is less than the supplied items. See demo
slideSpeed200intSlide speed in milliseconds
paginationSpeed800intPagination speed in milliseconds
rewindSpeed1000intRewind speed in milliseconds
autoPlayfalseint/booleanChange to any integrer for example autoPlay : 5000 to play every 5 seconds. If you setautoPlay: true default speed will be 5 seconds.
stopOnHoverfalsebooleanStop autoplay on mouse hover
navigationfalsebooleanDisplay "next" and "prev" buttons.
navigationText["prev","next"]arrayYou can cusomize your own text for navigation. To get empty buttons usenavigationText : false. Also HTML can be used here
rewindNavtruebooleanSlide to first item. Use rewindSpeed to change animation speed.
scrollPerPagefalsebooleanScroll per page not per item. This affect next/prev buttons and mouse/touch dragging.
paginationtruebooleanShow pagination.
paginationNumbersfalsebooleanShow numbers inside pagination buttons
responsivetruebooleanYou can use Owl Carousel on desktop-only websites too! Just change that to "false" to disable resposive capabilities
responsiveRefreshRate200intCheck window width changes every 200ms for responsive actions
responsiveBaseWidthwindowjQuery selectorOwl Carousel check window for browser width changes. You can use any other jQuery element to check width changes for example ".owl-demo". Owl will change only if ".owl-demo" get new width.
baseClass"owl-carousel"stringAutomaticly added class for base CSS styles. Best not to change it if you don't need to.
theme"owl-theme"stringDefault Owl CSS styles for navigation and buttons. Change it to match your own theme
lazyLoadfalsebooleanDelays loading of images. Images outside of viewport won't be loaded before user scrolls to them. Great for mobile devices to speed up page loadings. IMG need special markupclass="lazyOwl" and data-src="your img path"See example.
lazyFollowtruebooleanWhen pagination used, it skips loading the images from pages that got skipped. It only loads the images that get displayed in viewport. If set to false, all images get loaded when pagination used. It is a sub setting of the lazy load function.
lazyEffect"fade"boolean / stringDefault is fadeIn on 400ms speed. Use false to remove that effect.
autoHeightfalsebooleanAdd height to owl-wrapper-outer so you can use diffrent heights on slides. Use it only for one item per page setting.
jsonPathfalsestringAllows you to load directly from a jSon file. The JSON structure you use needs to match the owl JSON structure used here. To use custom JSON structure see jsonSuccess option.
jsonSuccessfalsefunctionSuccess callback for $.getJSON build in into carousel. See demo with custom JSON structurehere.
dragBeforeAnimFinishtruebooleanIgnore whether a transition is done or not (only dragging).
mouseDragtruebooleanTurn off/on mouse events.
touchDragtruebooleanTurn off/on touch events.
addClassActivefalsebooleanAdd "active" classes on visible items. Works with any numbers of items on screen.
transitionStylefalsestringAdd CSS3 transition style. Works only with one item on screen. See Demo

2. Callbacks

VariableDefaultTypeDescription
beforeUpdatefalsefunctionBefore responsive update callback
afterUpdatefalsefunctionAfter responsive update callback
beforeInitfalsefunctionBefore initialization callback
afterInitfalsefunctionAfter initialization callback
beforeMovefalsefunctionBefore move callback
afterMovefalsefunctionAfter move callback
afterActionfalsefunctionAfter startup, move and update callback
startDraggingfalsefunctionCall this function while dragging.
afterLazyLoadfalsefunctionCall this function after lazyLoad.

3. Defaults

Carousel default settings

  1. $("#owl-example").owlCarousel({
  2.  
  3. // Most important owl features
  4. items : 5,
  5. itemsCustom : false,
  6. itemsDesktop : [1199,4],
  7. itemsDesktopSmall : [980,3],
  8. itemsTablet: [768,2],
  9. itemsTabletSmall: false,
  10. itemsMobile : [479,1],
  11. singleItem : false,
  12. itemsScaleUp : false,
  13.  
  14. //Basic Speeds
  15. slideSpeed : 200,
  16. paginationSpeed : 800,
  17. rewindSpeed : 1000,
  18.  
  19. //Autoplay
  20. autoPlay : false,
  21. stopOnHover : false,
  22.  
  23. // Navigation
  24. navigation : false,
  25. navigationText : ["prev","next"],
  26. rewindNav : true,
  27. scrollPerPage : false,
  28.  
  29. //Pagination
  30. pagination : true,
  31. paginationNumbers: false,
  32.  
  33. // Responsive
  34. responsive: true,
  35. responsiveRefreshRate : 200,
  36. responsiveBaseWidth: window,
  37.  
  38. // CSS Styles
  39. baseClass : "owl-carousel",
  40. theme : "owl-theme",
  41.  
  42. //Lazy load
  43. lazyLoad : false,
  44. lazyFollow : true,
  45. lazyEffect : "fade",
  46.  
  47. //Auto height
  48. autoHeight : false,
  49.  
  50. //JSON
  51. jsonPath : false,
  52. jsonSuccess : false,
  53.  
  54. //Mouse Events
  55. dragBeforeAnimFinish : true,
  56. mouseDrag : true,
  57. touchDrag : true,
  58.  
  59. //Transitions
  60. transitionStyle : false,
  61.  
  62. // Other
  63. addClassActive : false,
  64.  
  65. //Callbacks
  66. beforeUpdate : false,
  67. afterUpdate : false,
  68. beforeInit: false,
  69. afterInit: false,
  70. beforeMove: false,
  71. afterMove: false,
  72. afterAction: false,
  73. startDragging : false
  74. afterLazyLoad : false
  75.  
  76. })

4. Custom Events

Owl Carousel handles a few basic events. Mainly use them for custom navigation. See Demo

  1. "owl.prev" //Go to previous
  2. "owl.next" //Go to next
  3. "owl.play" //Autoplay, also this event accept autoPlay speed as second parameter
  4. "owl.stop" //Stop
  5. "owl.goTo" //goTo provided item
  6. "owl.jumpTo" //jumpTo provided item. Without slide animation.

5. Owl Data methods

To use Owl Carousel $.data use delegate function.

  1.  
  2. //Initialize Plugin
  3. $(".owl-carousel").owlCarousel()
  4.  
  5. //get carousel instance data and store it in variable owl
  6. var owl = $(".owl-carousel").data('owlCarousel');
  7.  
  8. //Public methods
  9. owl.next() // Go to next slide
  10. owl.prev() // Go to previous slide
  11. owl.goTo(x) // Go to x slide
  12. owl.jumpTo(x) // Go to x slide without slide animation
  13.  
  14. //Auto Play
  15. owl.play() // Autoplay
  16. owl.stop() // Autoplay Stop
  17.  
  18. //Manipulation methods. See demo.
  19. owl.addItem(htmlString [,targetPosition])
  20. owl.removeItem(targetPosition)
  21. owl.destroy()
  22. owl.reinit(newOptions)

FAQ

Can i use it for free?
Yes!
Can i use it for ecommerce?
Yes!
Has it any licence?
MIT
Can i ask for a new functionality?
Yes! Use Github
I need help!
Send me an email, visit Github or add comment below.
Don't forget to add link to your demo/example website!
Does it has infinity scroll/circle/loop slides?
Only new version 2.x.x has it. Check it
What's new in latest release?
See Changelog


반응형