zoukankan      html  css  js  c++  java
  • Raphael的鼠标over move out事件

    Raphael的鼠标over move out事件

    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
    <%
        String path = request.getContextPath();
        String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
    %>
    <!DOCTYPE html>
    <html>
    <head>
    <base href="<%=basePath%>">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="js/jquery-1.11.1.js"></script>
    <script type="text/javascript" src="js/raphael.js"></script>
    <script type="text/javascript" src="js/index010.js"></script>
    </head>
    <body>
    <div id="container"></div>
    </body>
    </html>
    $(function() {
        initRaphael();
    });
    function initRaphael(e) {
        var paper = Raphael(0, 0, 500, 500);
        // var s = paper.rect(25, 25, 250, 250).attr('fill', 'red');
        // s.click(function(e) {
        // this.attr('fill', 'blue');
        // });
        // 线段点击有些问题,容易点击不上;
        var p = paper.path('M10,10L200,200');
        p.click(function(e) {
            var sW = this.attr('stroke-width');
            if (sW == 1) {
                this.attr('stroke-width', 2);
            } else {
                this.attr('stroke-width', 1);
            }
        }).mouseover(function(e) {
            this.attr('stroke-width', 2);
        }).mouseout(function(e) {
            this.attr('stroke-width', 1);
        });
        var square = paper.rect(200, 10, 50, 70).attr('fill', 'steelblue');
        var circle = paper.circle(120, 140, 25).attr('fill', 'yellow');
        var ellipse = paper.ellipse(60, 150, 30, 15).attr('fill', 'orange');
        var stuff = paper.set();
        stuff.push(square, circle, ellipse);
        var label = paper.text(10, 10, 'Mouse over an object').attr('text-anchor', 'start');
    //    stuff.mouseover(function(e) {
    //        label.attr({
    //            'text' : this.attr('fill'),
    //            x : e.clientX,
    //            y : e.clientY
    //        });
    //    }).mouseout(function(e) {
    //        label.attr('text', 'Mouse over an object...');
    //    });
        // stuff mouse事件改进
        stuff.mouseover(function (e) {
            label.attr('text',this.attr('fill'));
        }).mousemove(function (e) {
            label.attr({
                x:e.clientX+10,
                y:e.clientY
            });
        }).mouseout(function (e) {
            label.attr({
                x:10,
                y:10,
                text:'Mouse over an object...'
            })
        });
    }
  • 相关阅读:
    $.ajax 中的contentType
    如何能让MAC和PC都能读写移动硬盘
    bootstrap中的明星属性
    SQL Server2012如何导出sql脚本并且还原数据库
    Http 请求头中 X-Requested-With 的含义
    jquery实现模拟select下拉框效果
    ASP.NET应用技巧:非托管COM组件的使用
    COM和.NET的互操作
    NET调用Com组件事例
    com组件
  • 原文地址:https://www.cnblogs.com/stono/p/5053472.html
Copyright © 2011-2022 走看看