bannertime / generator-bannertime

Yeoman generator to help build and manage HTML5 banner campaigns.
https://bannertime.github.io/
58 stars 35 forks source link

fix: delete settings.src and settings.alt #73

Closed joemidi closed 7 years ago

joemidi commented 7 years ago

The way GSAP interprets strings causes issues when a file name such as cta-300x250.png is being set.

Example

  this.cta = this.smartObject({
    type: 'img',
    src: 'cta-300x250.png',
    alt: 'CTA',
    width: 200,
    height: 20,
    parent: this.banner
  });

// This produces the following 404 GET error: '.../images/cta-300xNaN.png` 404 (Not Found)

It would be beneficial to delete src and alt from the settings object before all items get set by TweenMax.

  function applySettings() {
    if (settings.id) {
      element.id = settings.id;
    }
    if (settings.parent) {
      settings.parent.appendChild(element);
    }
    if (settings.innerHTML) {
      element.innerHTML = settings.innerHTML;
    }
    delete settings.innerHTML;
    delete settings.retina;
    delete settings.parent;
    delete settings.id;
    delete settings.type;
    delete settings.autoplay;
    delete settings.loop;
    delete settings.controls;
    delete settings.muted;
    delete settings.poster;
    delete settings.preload;
    delete settings.sources;
    delete settings.src;
    delete settings.alt;
    TweenLite.set(element, settings);
  }