Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

removeEventListener never works #930

@giannoudak

Description

@giannoudak

Hello,

i am developing a library for a site, in which a have a scroll listener and check if a specific div is visible.
when i reach that point i immediately remove the scroll listener and do an ad call

the site where my library runs has the

http://cdnjs.cloudflare.com/ajax/libs/zone.js/0.8.18/zone.min.js

on it.

However although i remove the listener it continues to fire again and again. As a result a have multiple ad calls. I tried to block the zone.js script using ublock extention and everything works ok. So it seems that its a zone.js issue

heres is my code snippet

var addScrollListener = function(){


  if (isDebug()){
    window.addEventListener('scroll', onScroll);
  }

}

var onScroll = function(event){

  if (isAdVisible()){
    
    console.log(event);

    window.removeEventListener('scroll', onScroll);
    loadAdTad();
  }
}

var bindEvents = function(){
  addScrollListener();

}

bindEvents();

am i doing something wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions