基于jQuery实现Taggd图像标签提示特效



51 203 68



特效描述:基于jQuery实现 Taggd 图像标签提示,基于jQuery实现Taggd图像标签提示特效

代码结构

1. 引入CSS

<link rel="stylesheet" type="text/css" href="css/normalize.css" />
<link rel="stylesheet" type="text/css" href="css/taggd.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" />

2. 引入JS

<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="js/jquery.taggd.js"></script>

3. HTML代码

<div id="container">
    <div id="example">
        <img class="taggd" src="img/example.jpg" alt="photo" />
        <script type="text/javascript">
            data.push([
                { x: 0.512, y: 0.33, text: 'Huey' },
                { x: 0.548, y: 0.33, text: 'Dewey' },
                { x: 0.567, y: 0.36, text: 'Louie' }
            ]);
            settings.push({
                align: { 'y': 'bottom' },
                offset: { 'top': -15 },
                'handlers': {
                    'mouseenter': 'show',
                    'mouseleave': 'hide'
                }
            });
        </script>
    </div>
    <div class="content-wrapper">
	<img src="img/taggd.png" class="logo" alt="taggd" />
    <p>
        <strong>“A picture is worth a thousand words”</strong>, but sometimes 
		even a thousand words are just not enough.<br />
        <strong>Taggd</strong> is a jQuery plugin that help you create tags on images with, or without a 
		popup!
    </p>
    <ol>
        <li>
            <a href="#begin">Getting started</a>
            <ol>
                <li><a href="#download">Download</a></li>
                <li><a href="#basic-usage">Basic usage</a></li>
                <li><a href="#custom">Customization</a></li>
            </ol>
        </li>
        <li>
            Documentation
            <ol>
                <li>
                    <a href="#configuration">Configuration</a>
                    <ol>
                        <li><a href="#align">Align Object</a></li>
                        <li><a href="#handler">Handler Object</a></li>
                        <li><a href="#offset">Offset Object</a></li>
                    </ol>
                </li>
                <li>
                    <a href="#items">Items</a>
                    <ol>
                        <li><a href="#item">Item Object</a></li>
                    </ol>
                </li>
            </ol>
        </li>
        <li>
            Demo&#39;s
            <ol>
                <li><a href="#demo-0">Hover top popup</a></li>
                <li><a href="#demo-1">Click bottom popup</a></li>
                <li><a href="#demo-2">Click-mouseout left popup</a></li>
                <li><a href="#demo-3">Click custom</a></li>
            </ol>
        </li>
    </ol>
</div>
    <div id="begin">
        <div class="content-wrapper">
    <h2>Getting started</h2>
    <p>But, without data, there are no tags! We have to write just one more 
	line:</p>
    <pre>$( image ).taggd( &#39;items&#39;, data );</pre>
    <p>Read <a href="#items">Items</a> to learn how to set up the data.</p>
    <h3 id="custom">Customization</h3>
    <p>Of course, sometimes you want to do more than just a popup. By discarding 
	the <code>text</code> property of the <a href="#items">items</a>, and using 
	a function as <a href="#handler">Handler</a>, you can do whatever you want, 
	just like <a href="#demo-3">this demo</a>. If you need item-specific data in 
	the Handler, you can just add more properties to the <a href="#item">Item 
	Object</a>.</p>
    <p>CSS styles are easily customizable. Just edit or replace the CSS rules in 
	the file <code>css/taggd.css</code>.</p>
</div>
    </div>
    <div class="content-wrapper">
    <h2 id="configuration">Configuration</h2>
    <table>
        <thead>
        <tr>
            <td>Property</td>
            <td>Value</td>
            <td>Description</td>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td>align</td>
            <td><a href="#align">Align Object</a></td>
            <td>Popup aligning settings</td>
        </tr>
        <tr>
            <td>handlers</td>
            <td><a href="#handler">Handler Object</a></td>
            <td>Event handlers</td>
        </tr>
        <tr>
            <td>offset</td>
            <td><a href="#offset">Offset Object</a></td>
            <td>Offset of the hover element in pixels</td>
        </tr>
        </tbody>
    </table>
</div>
<div class="content-wrapper">
    <h3 id="align">Align Object</h3>
    <p>Aligning is two-dimensional; the X-axis and the Y-axis. When you align an 
	object <strong>left</strong>, the <strong>left side</strong> is snapped 
	against the button.</p>
    <table>
        <thead>
        <tr>
            <td>Property</td>
            <td>Value</td>
            <td>Default</td>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td>x</td>
            <td><code>String</code> left, right or center</td>
            <td>center</td>
        </tr>
        <tr>
            <td>y</td>
            <td><code>String</code> top, bottom or center</td>
            <td>center</td>
        </tr>
        </tbody>
    </table>
    <h4>Example</h4>
    <pre>{
    x: 13,
    y: 37
}</pre>
</div>
<div class="content-wrapper">
    <h3 id="handler">Handler Object</h3>
    <p>Handlers are used to add actions to the buttons. These are JavaScript 
	events like <code>click</code>, <code>mouseenter</code>, etc.<br />The 
	handler can be a function, or a string for popup interaction.</p>
    <table>
        <thead>
        <tr>
            <td>String</td>
            <td>Description</td>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td>show</td>
            <td>Shows the popup</td>
        </tr>
        <tr>
            <td>hide</td>
            <td>Hides the popup</td>
        </tr>
        <tr>
            <td>toggle</td>
            <td>Toggles the popup visability</td>
        </tr>
        </tbody>
    </table>
    <h4>Example</h4>
    <pre>{
    click: function() {
        alert(&#39;You clicked the tag!&#39;);
    },
    mouseenter: &#39;show&#39;,
    mouseleave: &#39;hide&#39;
}</pre>
</div>
<div class="content-wrapper">
    <h3 id="offset">Offset Object</h3>
    <p>The offset is the offset of the popup in pixels.</p>
    <table>
        <thead>
        <tr>
            <td>Property</td>
            <td>Value</td>
            <td>Default</td>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td>left</td>
            <td><code>Number</code></td>
            <td>0</td>
        </tr>
        <tr>
            <td>top</td>
            <td><code>Number</code></td>
            <td>0</td>
        </tr>
        </tbody>
    </table>
    <h4>Example</h4>
    <pre>{
    left: 13,
    top: 37
}</pre>
</div>
<div class="content-wrapper">
    <h2 id="items">Items</h2>
    <p>Items are what drives taggd. Without items, there&#39;s no way it would know 
	where to put the tags and popups. That&#39;s why, we need items.</p>
    <p>Items can be set with the following line, where <code>data</code> is an 
	array of <a href="#item">Item Objects</a>.</p>
    <pre>$( image ).taggd( &#39;items&#39;, data );</pre>
</div>
<div class="content-wrapper">
    <h3 id="item">Item Object</h3>
    <table>
        <thead>
        <tr>
            <td>Property</td>
            <td>Description</td>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td><code>Float</code> x</td>
            <td>X position of the tag (and popup)</td>
        </tr>
        <tr>
            <td><code>Float</code> y</td>
            <td>Y position of the tag (and popup)</td>
        </tr>
        <tr>
            <td><code>String</code> text</td>
            <td>Optional. Set&#39;s the text of the popup. If omitted, there will be 
			no popup.</td>
        </tr>
        </tbody>
    </table>
    <p>The <code>x</code> and <code>y</code> property can be in a scale from 0 
	to 1, or a number in pixels based on the image&#39;s dimensions. Both are 
	scalable.</p>
    <p>This object also accepts custom properties, that can be read using a <a href="#handler">
	Handler</a>.</p>
    <h4>Example</h4>
    <pre>{
    x: 0.5,
    y: 0.5,
    text: &#39;Popup text&#39;
}</pre>
</div>
    <div id="demo-0">
    <img class="taggd" src="img/demo-0.jpg" alt="photo" />
    <div class="content-wrapper">
        <h3>Settings</h3>
                <pre>{
    align: {
        y: &#39;bottom&#39;
    },
    offset: {
        top: -15
    },
    handlers: {
        mouseenter: &#39;show&#39;,
        mouseleave: &#39;hide&#39;
    }
}</pre>
        <h3>Items</h3>
                <pre>[
    { x: 1099,  y: 220,  text: &#39;Dave&#39;   }, // pixel-based
    { x: 0.431, y: 0.33, text: &#39;Phil&#39;   }, // scale (0 - 1)
    { x: 0.468, y: 0.28, text: &#39;Steven&#39; }
]</pre>
    </div>
    <script type="text/javascript">
        data.push([
            { x: 0.572, y: 0.343, text: 'Dave' },
            { x: 0.431, y: 0.33, text: 'Phil' },
            { x: 0.468, y: 0.28, text: 'Steven' }
        ]);
        settings.push({
            align: { 'y': 'bottom' },
            offset: { 'top': -15 },
            'handlers': {
                'mouseenter': 'show',
                'mouseleave': 'hide'
            }
        });
    </script>
</div>
<div id="demo-1">
    <img class="taggd" src="img/demo-1.jpg" alt="photo" />
    <div class="content-wrapper">
        <h3>Settings</h3>
            <pre>{
    align: {
        y: &#39;top&#39;
    },
    offset: {
        top: 15
    },
    handlers: {
        click: &#39;toggle&#39;
    }
}</pre>
        <h3>Items</h3>
            <pre>[
    { x: 0.62, y: 0.7, text: &#39;Rope&#39;             },
    { x: 0.51, y: 0.5, text: &#39;Bird&#39;             },
    { x: 0.40, y: 0.3, text: &#39;Water, obviously&#39; }
]</pre>
    </div>
    <script type="text/javascript">
        data.push([
            { x: 0.62, y: 0.7, text: 'Rope' },
            { x: 0.51, y: 0.5, text: 'Bird' },
            { x: 0.40, y: 0.3, text: 'Water, obviously' }
        ]);
        settings.push({
            align: { 'y': 'top' },
            offset: { 'top': 15 },
            'handlers': {
                'click': 'toggle'
            }
        });
    </script>
</div>
<div id="demo-2">
    <img class="taggd" src="img/demo-2.jpg" alt="photo" />
    <div class="content-wrapper">
        <h3>Settings</h3>
            <pre>{
    align: {
        x: &#39;right&#39;
    },
    offset: {
        left: -15
    },
    handlers: {
        click: &#39;show&#39;,
        mouseleave: &#39;hide&#39;
    }
}</pre>
        <h3>Items</h3>
            <pre>[
    { x: 0.415, y: 0.343, text: &#39;Leaf&#39;                   },
    { x: 0.25,  y: 0.33,  text: &#39;More water&#39;             },
    { x: 0.8,   y: 0.1,   text: &#39;This used to be a tree&#39; }
]</pre>
    </div>
    <script type="text/javascript">
        data.push([
            { x: 0.415, y: 0.343, text: 'Leaf' },
            { x: 0.25, y: 0.33, text: 'More water' },
            { x: 0.8, y: 0.1, text: 'This used to be a tree' }
        ]);
        settings.push({
            align: { 'x': 'right' },
            offset: { 'left': -15 },
            'handlers': {
                'click': 'show',
                'mouseleave': 'hide'
            }
        });
    </script>
</div>
<div id="demo-3">
    <img class="taggd" src="img/demo-3.jpg" alt="photo" />
    <div class="content-wrapper">
        <h3>Settings</h3>
            <pre>{
    align: {
        y: &#39;bottom&#39;
    },
    offset: {
        top: -12
    },
    handlers: {
        click: function( e ) {
            var wiki = &#39;http://en.wikipedia.org/wiki/&#39; + e.data.uri;
            window.open( wiki, &#39;_blank&#39; );
        },
        mouseenter: &#39;show&#39;,
        mouseleave: &#39;hide&#39;
    }
}</pre>
        <h3>Items</h3>
            <pre>[
    { x: 0.1,  y: 0.54, text: &#39;Auto Rickshaw&#39;,      uri: &#39;Auto_rickshaw&#39;              },
    { x: 0.49, y: 0.57, text: &#39;Registration Plate&#39;, uri: &#39;Vehicle_registration_plate&#39; },
    { x: 0.38, y: 0.9,  text: &#39;Lighting&#39;,           uri: &#39;Automotive_lighting&#39;        }
]</pre>
    </div>
    <script type="text/javascript">
        data.push([
            { x: 0.1, y: 0.54, text: 'Auto Rickshaw', uri: 'Auto_rickshaw' },
            { x: 0.49, y: 0.57, text: 'Registration Plate', uri: 'Vehicle_registration_plate' },
            { x: 0.38, y: 0.9, text: 'Lighting', uri: 'Automotive_lighting' }
        ]);
        settings.push({
            'align': { 'y': 'bottom' },
            'offset': { 'top': -12 },
            'handlers': {
                'click': function(e) {
                    var wiki = 'http://en.wikipedia.org/wiki/' + e.data.uri;
                    window.open(wiki, '_blank');
                },
                mouseenter: 'show',
                mouseleave: 'hide'
            }
        });
    </script>
</div>
</div>
<div style="text-align:center;clear:both">
</div>



用户评论
大牛,别默默的看了,快登录帮我点评一下吧!:)      登录 | 注册


热门标签: 文字叠加 文字层叠 文字淡出淡进 文字淡出 文字淡进 文字翻转 文字旋转 文字放大缩小 文字缩放 文字大小 文字放大 文字缩小 文字变大 文字变小 文字收缩展开 文字收缩 文字展开 文字提示框 提示文字 文字全屏 文字拖动 文字拖拽 文字延迟加载 文字延迟 文字加载 h5文字动画 h5文字边框动画 html5文字动画 html5文字边框动画 360全景 360度全景 文字滑动 文字滑块 文字滚动 文字无缝滚动 文字间歇滚动 弹出层拖动 文字切换 文字选项卡 全屏焦点图 窗口 弹出 弹窗 弹出层 提示框 对话框 遮罩 遮罩层 弹窗插件 滑动星星打分 图片文字 文字导航菜单 文字导航 文字菜单 全屏切换 宽屏全屏 宽屏 全屏 页面全屏 页面宽屏 文字 文字插件 其他 图片全屏 文字标签 文字标签云 标签云 文字提示框 提示文字 鼠标滑过 鼠标悬停 跟随鼠标移动

×
×

注册

官方QQ群

扫描上面二维码加微信群

官方QQ群

jQuery/js讨论群
群号:642649996
Css3+Html5讨论群
群号:322131262

加群请备注:从官网了解到