Worker
Worker

Reputation: 283

Uncaught TypeError: Cannot read property 'on' of undefined in raphael.js

Was using justgage node_module in the below code. On importing raphael.js for the same, getting the error Uncaught TypeError: Cannot read property 'on' of undefined. When I checked the method giving issue in the file, it was found that the method was already defined in the code. Code giving issue is eve.on("raphael.remove", stopAnimation); on line 5216 in raphael.js but this method was already defined on line 185 as eve.on = function (name, f){}. Can anybody tell what is the problem ?

Code -

import React from 'react';
import 'justgage';
import 'raphael';

var timeOut=null,gauge=null;

export default React.createClass({

        componentDidMount(){            
            this.update();                  
        },

        update(){

            gauge=new JustGage({ id: "gauge", value: 67, min: 0, max: 100, title: "Visitors"});
            document.getElementById("gage").innerHTML = gauge;      

            timeOut=setTimeout(this.update, 600);       
        },

        getValue(){
         var val = 25*Math.random();
            if(val>100) { val=100-val;}
            if(val<0)   { val=val+10;}
          return val;
        },

      componentWillUnmount: function() {        
         clearTimeout(timeOut);
      },

       render(){
                return(<div className="coll-md-4">
                         <div id="gage"></div>  
                       </div>);
            }
});

Upvotes: 1

Views: 991

Answers (1)

Raman Andryianau
Raman Andryianau

Reputation: 11

Try to use https://www.npmjs.com/package/webpack-raphael package.

ps. if you haven't jQuery available globally, you can pass using imports-loader module:

import 'imports-loader?jQuery=jquery,this=>window!webpack-raphael/raphael';

Upvotes: 1

Related Questions