creativelive / appear

execute callbacks when dom elements appear in and out of view
http://creativelive.github.io/appear/
MIT License
178 stars 43 forks source link

Appear not defined #23

Open vtvhunter opened 5 years ago

vtvhunter commented 5 years ago

Hi,

We were using an earlier version of appear.js (1.0.3) and we were able to use it fine (called it using the sample code you provided on your website, appear({object content here})). I tried a new project with the latest version and I am getting "appear is not defined" error inside Console. Do we need to assign it to a variable or another object and then execute it? Or does it has something to do with module imports/exports? Sorry, i'm not the most experienced person with JS but just noticed this and wanted to know if it had something to do with the way I was calling it or not.

Thanks

jackmcdade commented 5 years ago

Same issue here.

philliphartin commented 5 years ago

Also having the same issue.

alexhisen commented 5 years ago

This was introduced in the recent change to be compatible with webpack. The extra nested return function(obj) is not actually being executed, just defined, so this file no longer works to just load as a script in html.

retailonline commented 5 years ago

so this file no longer works to just load as a script in html.

So how do I load it into html so I can use it as before?

cawecoy commented 5 years ago

Appear.js' example is not working.

<script src="http://localhost/js/appear.min.js"></script>
<script type="text/javascript">
var trackElementsViews = appear({
  init: function init(){
    console.log('dom is ready');
  },
  elements: function elements(){
    // work with all elements with the class "track"
    return document.getElementsByClassName('track');
  },
  appear: function appear(el){
    console.log('visible', el);
  },
  disappear: function disappear(el){
    console.log('no longer visible', el);
  },
  bounds: 200,
  reappear: true
});
</script>

Firefox console displays: ReferenceError: appear is not defined.

What can I do to solve this?

cawecoy commented 5 years ago

Anyway, the older version (practically the same as the newer version) is working as I expect.

trabdlkarim commented 3 years ago

For those still looking for a fix to this bug, there is an open pull request from @tehmi2000 that fixes it. It worked for me, you should get the updated code from here