`
23号
  • 浏览: 137104 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

jQuery plugin - Easy Image or Content Slider

阅读更多

This is my first jQuery plugin. I wrote several jQuery scripts but never made a real plugin just because I was I afraid of it's complexity. It turned out to be a lot easier than I thought so I went ahead and created this one.
Easy Slider (as I call this plugin) enables images or any content to slide horizontally or vertically on click. It is configurable with css alone. So, basically you link to plugin file, set the content up and style it with css.

Download easySlider.zip

Getting Started

First you'll need content and it should be wrapped inside a div containing an ordered list where each list item represents one slide. Here's a markup example:

<div id="slider">
<ul>

<li>content here...</li>
<li>content here...</li>
<li>content here...</li>
...
</ul>
</div>

You can basically put whatever you want inside list items as long as you keep the same dimensions. My initial idea was to use this slider for image gallery as on Templatica's homepage but I've used it for other stuff too.
To activate the script you will need to download the files, place jQuery file and easySlider.js somewhere on your site and link to them:

<script type="text/javascript" src="/js/jquery.js"></script>
<script type="text/javascript" src="/js/easySlider.js"></script>

The action starts when you add this lines of code to your JavaScript:

$(document).ready(function(){
$("#slider").easySlider();
});

This basically initiates the script on page load where "#slider" is css selector of the element(s) that you wish to apply script to. You can also use multiple elements using their class names i.e. $(".list").easySlider();

Next is up to your preferences - styling. This is how default styling looks like:

#slider ul, #slider li{
margin:0;
padding:0;
list-style:none;
}
#slider, #slider li{
width:500px;
height:200px;
overflow:hidden;
}
span#prevBtn{}
span#nextBtn{}

Not much there, is it? The most important thing here is to keep the same dimensions for the content area and each list item (slide). Also, overflow:hidden is obligatory. Other than that, you have free hands in adding your own style to the Easy Slider! To get an idea how it can be spiced up, you may take a look at Templatica's homepage.

How does it all work

Script automatically adds "previous" and "next" buttons in form of span elements with nested anchors just after the content element. Spans have assigned IDs that you can use for css selecting:

<span id="prevId"><a href="javascript:void(0);">Previous</a></span> 
<span id="nextBtn"><a href="javascript:void(0);">Next</a></span>

On each click (previous or next button) script calculates the current "position" and makes a one step in requested direction. So, the slider jumps from one slide to another. Once it reaches the end (last slide), the "next" button fades away and re-appears only if "previous" button is clicked again. Same goes for sliding towards the beginning.

Options

The following options are configurable:

  • prevId - id for "previous" button
  • prevText - text for "previous" button
  • nextId - id for "previous" button
  • nextText - text for "next" button
  • orientation - horizontal or vertical, horizontal is default and if you want vertical set this to 'vertical'
  • speed - animation speed in milliseconds, default value is 800

Yes, you saw it correctly, vertical sliding is also possible! :)

Options are added when calling the script:

$(document).ready(function(){ 
$("#slider").easySlider({
prevText: 'Previous Slide',
nextText: 'Next Slide',
orientation: 'vertical'
});
});

Make sure that you don't put the comma after last option.

Demos

Here are some blank, non styled demos. Check out the script in action:

To check out styled demo, please visit Templatica.

What makes this slider script different

Because of it's simplicity and light-weightness (is that a word ?! ) I believe that is is much easier to deal with this plug in and configure it. The appearance is totally editable with css so all of you afraid of getting their hands dirty with JS code can easily use this.

 

from http://cssglobe.com/post/3783/jquery-plugin-easy-image-or-content-slider

分享到:
评论

相关推荐

    struts2-jquery-plugin-3.1.0.jar

    struts2-jquery-plugin-3.1.0.jar

    struts2-jquery-plugin-2.0.0

    struts2-jquery-plugin-2.0.0 struts2-jquery-plugin-2.0.0 struts2-jquery-plugin-2.0.0

    jQuery-Plugin-for-Client-Side-Image-Resizing-canvasResize

    《jQuery-Plugin-for-Client-Side-Image-Resizing-canvasResize:基于canvas的前端图片缩放技术详解》 在Web开发中,处理用户上传的图片大小和格式问题是一项常见任务。为了提高用户体验并减轻服务器压力,我们经常...

    tableExport.jquery.plugin-master

    tableExport.jquery.plugin-master能够将这些数据导出为多种格式,如CSV(逗号分隔值)、Excel(.xlsx)、PDF等,方便用户在不同的场景下使用和处理这些数据。 在压缩包"tableExport.jquery.plugin-master"中,可能...

    atlassian-universal-plugin-manager-plugin-2.17.13.jar

    将atlassian-universal-plugin-manager-plugin-2.17.13.jar 替换到 jira/atlassian-jira-6.3.6-standalone/atlassian-jira/WEB-INF/atlassian-bundled-plugins/ 重新启动jira 用管理员账户登录jira

    cordova-plugin-ImagePicker-master.zip

    ionic3使用cordova-plugin-ImagePicker 插件实现仿微信相册选图。因为直接add plugin 下载不下来。故直接github上下载然后打包上传以便日后使用

    Jquery-Image-Zoom-Plugin-elevatezoom.zip

    **jQuery Image Zoom Plugin - elevateZoom** `elevateZoom` 是一个基于jQuery的图像缩放插件,它为网页中的图像提供了平滑、高效的放大功能,增强了用户体验。这个插件适用于电子商务网站,产品展示,或者任何需要...

    jQuery摄像头插件jquery-webcam-plugin

    **jQuery摄像头插件jquery-webcam-plugin** 在网页开发中,集成摄像头功能可以帮助用户实时捕捉图像,广泛应用于在线证件照上传、视频聊天、虚拟试衣间等场景。`jQuery webcam plugin`是一个优秀的JavaScript库,它...

    jQuery Lightbox Plugin--缩图查看插件,图片查看器

    《jQuery Lightbox Plugin——打造极致图片查看体验》 在网页设计和开发中,为了提供优质的用户体验,图片查看功能显得尤为重要。jQuery Lightbox Plugin就是这样一款专为网页图片展示而设计的插件,它基于流行的...

    hadoop-eclipse-plugin-2.10.0.jar

    - `hadoop2x-eclipse-plugin-master/ivy/library.properties` - `hadoop2x-eclipse-plugin-master/src/contrib/eclipse-plugin/build.xml` 开源源地址: https://github.com/winghc/hadoop2x-eclipse-plugin

    hadoop-eclipse-plugin-2.7.3和2.7.7

    hadoop-eclipse-plugin-2.7.3和2.7.7的jar包 hadoop-eclipse-plugin-2.7.3和2.7.7的jar包 hadoop-eclipse-plugin-2.7.3和2.7.7的jar包 hadoop-eclipse-plugin-2.7.3和2.7.7的jar包

    struts2-spring-plugin-2.3.15.2.jar ; struts2-json-plugin-2.3.16.3.jar

    struts2-spring-plugin-2.3.15.2.jar ; struts2-json-plugin-2.3.16.3.jarstruts2-spring-plugin-2.3.15.2.jar ; struts2-json-plugin-2.3.16.3.jar

    jQuery plugin for autocomplete - jQuery自动完成插件

    jQuery plugin for autocomplete - jQuery自动完成插件

    axis2-eclipse-codegen-plugin-1.6.2和axis2-eclipse-service-plugin-1.6.2

    标题中的"axis2-eclipse-codegen-plugin-1.6.2和axis2-eclipse-service-plugin-1.6.2"指的是两个与Apache Axis2相关的Eclipse插件:Axis2代码生成插件和Axis2服务插件,它们是版本1.6.2的。Apache Axis2是一个流行的...

    jquery-plugin-boxy

    "jQuery-plugin-boxy"是一个基于jQuery的弹出框插件,用于创建可定制的对话框和模态窗口。这个插件提供了丰富的功能和灵活性,帮助开发者在网页中轻松实现各种类型的提示信息或交互式表单。 1. **jQuery库基础**: ...

    [confluence插件] drawio-confluence-plugin-11.2.5.ocr

    drawio-confluence-plugin-11.2.5 drawio-confluence-plugin-11.2.5 drawio-confluence-plugin-11.2.5 drawio-confluence-plugin-11.2.5 drawio-confluence-plugin-11.2.5 drawio-confluence-plugin-11.2.5 drawio-...

    hadoop-eclipse-plugin-3.3.1.jar

    Ubuntu虚拟机HADOOP集群搭建eclipse环境 hadoop-eclipse-plugin-3.3.1.jar

    jquery-plugin-circliful-master.zip

    "jquery-plugin-circliful-master.zip" 是一个专门用于创建环形统计动画图的jQuery插件,它提供了一种独特而吸引人的方法来展示各种统计数据。环形图以其直观的视觉效果,可以清晰地传达百分比信息,适用于系统门户...

    好用hadoop-eclipse-plugin-1.2.1

    hadoop-eclipse-plugin-1.2.1hadoop-eclipse-plugin-1.2.1hadoop-eclipse-plugin-1.2.1hadoop-eclipse-plugin-1.2.1

    audit-plugin-mysql-5.7-1.1.7 for Linux

    mysql 5.7安全审计插件 Linux X86-X64通用...audit-plugin-mysql-5.7-1.1.7 for Linux 等保开启审计插件,貌似官网找不到,发出来共享. 缺点:日志信息比较大,对性能影响大。 优点:对每一时刻每一用户的操作都有记录。

Global site tag (gtag.js) - Google Analytics