Skip to content

Instantly share code, notes, and snippets.

@perrygovier
Created May 6, 2015 21:30
Show Gist options
  • Save perrygovier/64f58cb7c1518ba241c4 to your computer and use it in GitHub Desktop.
Save perrygovier/64f58cb7c1518ba241c4 to your computer and use it in GitHub Desktop.
Casper the Friendly Ghost Click
.directive('casper',function(){
return {
restrict: 'A',
link: function (scope, element){
element[0].style['position'] = 'relative';
var iframe = element[0].querySelector('iframe')
if (!iframe) return;
var dimensions = {
height:element[0].clientHeight,
width:element[0].clientWidth
}
var blockerEl = angular.element('<div class="blockerEl"></div>')
element.append(blockerEl)
blockerEl = element[0].querySelector('.blockerEl')
blockerEl.style.position = 'absolute';
blockerEl.style.height = dimensions.height+'px';
blockerEl.style.width = dimensions.width+'px';
blockerEl.style.top = 0;
blockerEl.addEventListener('click',function(e){
console.log('click')
})
blockerEl.addEventListener('touchstart',function(e){
console.log('touchstart')
})
blockerEl.addEventListener('touchend',function(e){
console.log('touchend')
blockerEl.style.display = 'none';
setTimeout(function(){
blockerEl.style.display = 'block';
},800)
})
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment