Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for use with ember-wormhole #14

Open
mbiondo opened this issue May 4, 2015 · 14 comments
Open

Adding support for use with ember-wormhole #14

mbiondo opened this issue May 4, 2015 · 14 comments

Comments

@mbiondo
Copy link

mbiondo commented May 4, 2015

No description provided.

@DanielOchoa
Copy link
Contributor

I'll definitely look into it.

@RuslanZavacky
Copy link

yeap, ti might be very useful. When ember-liquidfire is in use, it gives full page height, and photoswipe renders in the middle of nowhere :)

@gnazarkin
Copy link

^having the same issue

@evoactivity
Copy link

Is this project no longer maintained?

@lougreenwood
Copy link

I suppose that if this feature were to be added now it might make sense to use the new in-element feature?

emberjs/rfcs#287

@MrChriZ
Copy link

MrChriZ commented Aug 13, 2018

Just ran into this problem too...

@RuslanZavacky
Copy link

I would suggest looking into https://github.com/glidejs/glide - as it worked well for me as a replacement for this library. And you don't need much integration with ember.

@evoactivity
Copy link

I don't think glide is a good replacement at all, they do different things.

I think with ember-auto-import it should be fairly simple for people to roll their own photoswipe backed components though.

@RuslanZavacky
Copy link

@evoactivity indeed, apologies. Confused this addon with owl carousel :) I didn't have particular love to photoswipe and owl carousel... so ditched photoswipe and used glide instead of owl.

@MrChriZ
Copy link

MrChriZ commented Aug 14, 2018

So it seems the in-element feature isn't available yet in Ember. If you try you get an error message saying you can't use in-element. I read things about using a private API using -in-element but couldn't seem to get that to work at all - the element never moved.

I then had a play with ember-wormhole. I moved the pswp element into it's own component such that it looked like this:
ember-cli-photoswipe/app/templates/components/photo-swipe.hbs

{{#if options.destination}}
  <div>
    {{#ember-wormhole to=options.destination}}
      {{pswp-element}}
    {{/ember-wormhole}}
  </div>
{{/if}}

Unfortunately this however broke the ember photoswipe component which uses jquery to find the pswp component.
/ember-cli-photoswipe/addon/components/photo-swipe.js

this.set("pswpEl", this.$(".pswp")[0]);

Since it's been wormholed it can no longer be found.
I found this issue which describes this issue:
yapplabs/ember-wormhole#31
There's a number of potential solutions there including using the destination with a global jquery request which seemed to work.
ember-cli-photoswipe/addon/components/photo-swipe.js

  if (this.get("options.destination")) {
        let destinationElement = "#" + this.get("options.destination") + " .pswp";
        this.set("pswpEl", Ember.$(destinationElement)[0]);
      } else {
        this.set("pswpEl", this.$(".pswp")[0]);
      }

Then it's just a case of putting the destination in to the options. So I created a third example on the application.hbs page
tests/dummy/app/templates/application.hbs

<!-- example 3 - with destination -->
<h3>Example with destination</h3>
{{#photo-swipe options=psThreeOpts items=items as |image|}}
    <img class="thumb" src={{image.src}} alt={{image.title}}>
{{/photo-swipe}}

/tests/dummy/app/controllers/application.js

  psThreeOpts: {
    destination:'destination'
  }

I've pushed a copy of this to here:
https://github.com/MrChriZ/ember-cli-photoswipe/tree/addEmberWormhole

I've not added a pull request as yet though as I thought I'd just get peoples thoughts first.

@lougreenwood
Copy link

@MrChriZ nice work!

I haven't tried it yet, but I believe you need the in-element polyfill: https://github.com/kaliber5/ember-in-element-polyfill#readme

@MrChriZ
Copy link

MrChriZ commented Aug 14, 2018

Thanks - I did have a go with the polyfill as well but couldn't seem to get anywhere with it.
Probably was missing something obvious.

@MrChriZ
Copy link

MrChriZ commented Aug 15, 2018

RuzlanZavacy mentioned liquid-fire above.
I'm also using this and thought I'd also just mention that I needed to kill some of liquid-fires built in CSS
Like so:

.liquid-container {
  position: initial;
  
  -webkit-transform: initial;
  -moz-transform: initial;
  transform: initial;
}

These were causing the photoswipe animation to start in the wrong place.
In my case this doesn't seemed to have caused any issues - however I've not done extensive browser testing as yet so YMMV.


Additional note. Ember wormhole and Liquid fire don't seem to work well together 👎
The wormhole stops working after a transition.

@MrChriZ
Copy link

MrChriZ commented Aug 16, 2018

The polyfill wasn't compatible with the latest version of Ember - this has now been fixed.

With a little help from the author of the in-element polyfill I managed to get in-element working - removing the need for ember-wormhole:
https://github.com/MrChriZ/ember-cli-photoswipe/tree/useInElement

I have a bug I'm still thinking about which is that the consuming application has to manually add the polyfill in:

ember install ember-in-element-polyfill

I have the polyfill as a dependency rather than a dev dependency in ember-cli-photoswipe... and as such the polyfill installs with ember-cli-photoswipe... but then doesn't seem to get picked up by the browser. Manually installing the polyfill on the consuming application fixes the problem 😕

Unfortunately... in-element doesn't solve the Liquid-fire problem. 😬

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants