Last active
July 13, 2017 01:05
-
-
Save Techn1x/0cacdbef9ed2f7036e40ee24e0c8d04e to your computer and use it in GitHub Desktop.
SVG Popover troubleshooting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
// Simulate data coming in from API via an actioncable every 2 seconds | |
// Essentially just causes the SVG to redraw | |
dataFromAPI: Ember.observer('', function() { | |
var _that = this; | |
setInterval(function() { | |
_that.set('trailer', {tyres:[ | |
{id: 1, name:Math.random(1), x:0, y:100}, | |
{id: 2, name:Math.random(1), x:50, y:50}, | |
{id: 3, name:Math.random(1), x:100, y:100}, | |
{id: 4, name:Math.random(1), x:150, y:50}, | |
{id: 5, name:Math.random(1), x:200, y:100}, | |
{id: 6, name:Math.random(1), x:250, y:50}, | |
{id: 7, name:Math.random(1), x:300, y:100}, | |
{id: 8, name:Math.random(1), x:350, y:50}, | |
{id: 9, name:Math.random(1), x:400, y:100} | |
]}); | |
// Update the hovered tyre data in the popover | |
var hovTyre = _that.get('hoveredTyre'); | |
if(hovTyre) { | |
_that.get('trailer.tyres').forEach((tyre) => { | |
if(tyre.id === hovTyre.id) { | |
_that.set('hoveredTyre', tyre); | |
} | |
}); | |
} | |
}, 2000); | |
}).on('init'), | |
visiblePopover: false, | |
visiblePopoverComputed: Ember.computed('visiblePopover', function() { | |
return this.get('visiblePopover'); | |
}), | |
hoveredTyre: undefined, | |
hoveredTyreComputed: Ember.computed('hoveredTyre',function() { | |
return this.get('hoveredTyre'); | |
}), | |
actions: { | |
hoverAction: function(tyre) { | |
this.set('visiblePopover', true); | |
this.set('hoveredTyre',tyre); | |
}, | |
leaveAction: function() { | |
this.set('visiblePopover', false); | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
tagName: 'g' | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.12.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.12.0", | |
"ember-template-compiler": "2.12.0", | |
"ember-testing": "2.12.0" | |
}, | |
"addons": { | |
"ember-data": "2.12.1", | |
"ember-bootstrap": "1.0.0-beta.2", | |
"ember-truth-helpers": "1.3.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment