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

Before image not the same size than After image when resize height and width #2

Open
Crustybat08 opened this issue Oct 4, 2019 · 11 comments
Assignees
Labels
bug Something isn't working

Comments

@Crustybat08
Copy link

Hello,
I'm resizing two images to display the comparison in a confluence page.
The result is the before image is smaller than the after image.
It looks like the before image is reduced twice and display at 25% compare to 50% for the after image.
Do you think you can fix this issue ?
Thanks

@Crustybat08 Crustybat08 changed the title Before image not the good size when resize height and width Before image not the same size than After image when resize height and width Oct 4, 2019
@v20100v
Copy link
Owner

v20100v commented Oct 4, 2019

Hello,

You are right,I had found the same bug but i didn't find the time to fix it.
In my opinion this is a simple bug css - fix height. If you want to contribute, it would be a pleasure ^^. and if not I'd try to see if I can do it

Thank you for your return

@Crustybat08
Copy link
Author

Crustybat08 commented Oct 9, 2019

Sorry but i'm a real newbie in css i take a quick look and I don't really find the root of this issue.... So i you have a little bit of time to fix it i will be very gratefull !

@v20100v v20100v mentioned this issue Oct 15, 2019
@v20100v
Copy link
Owner

v20100v commented Oct 15, 2019

Hello @Crustybat08

I found the problem in the code source of https://github.com/sylvaincombes/jquery-images-compare.

To fix it, i choose to

  • Get the slider size by parsing parameters height and width given in macro
  • Resize images in slider (after and before) with keeping apsect ratio
  • Resize the frontElement (image-compare-before) with size's image
  • And finally resize the slider.

I tested different use cases: with percentage or fixed size, And everything seems fine

image

@v20100v v20100v closed this as completed Oct 15, 2019
@v20100v v20100v reopened this Oct 15, 2019
@v20100v v20100v added the bug Something isn't working label Oct 15, 2019
@v20100v v20100v self-assigned this Oct 15, 2019
@Crustybat08
Copy link
Author

Thanks a lot for the fix ! that's great ! I will test this asap

@Crustybat08
Copy link
Author

Hello,
First of all ! Happy new year !
Sorry to get back to you on this one, but we found another bug when we are using multiple image comparison in the same page.
I don't know why but only on the first one the rescale/resize work properly.
I tried with pourcentage and pixel but i can't make it work for the second instances....
Do you have any idea of what's going on ?

For infos we also had an update on confluence version we use now : Confluence 7.1.2
Maybe it's related...

Anyway thanks a lot for your help on this !

@v20100v
Copy link
Owner

v20100v commented Jan 8, 2020 via email

@Crustybat08
Copy link
Author

Thanks for the feedback !
We take a quick look and each instances has a different ID.
But we realize if we made a refresh with F5 of the page, the second times all the instances are working normally.
So maybe it's because the script is faster than image loading or something like that.
It seems to be a problem of synchronisation more than logic.
I hope it helps !

@v20100v
Copy link
Owner

v20100v commented Jan 10, 2020

We take a quick look and each instances has a different ID.

Ok sound greats ! There here no problem with html IDs. You can see the definition of html ID here :

#set($id=$action.dateFormatter.calendar.timeInMillis)
(...)
var slider = window.parent.AJS.${jQuery}('${hashtag}image-comparison-slider-${id}');

But we realize if we made a refresh with F5 of the page, the second times all the instances are working normally. So maybe it's because the script is faster than image loading or something like that.

Ok that's ugly :(
U right, in js we modify the DOM of html page. I take a lookaround in velocity, and i hope find an idea.

@v20100v
Copy link
Owner

v20100v commented Jan 10, 2020

Try to pu a timeout (setTimeout) 1 or 2 sec on initilaization of slider.

In row 184 :

// Init plugin jquery-images-compare 
var slider = window.parent.AJS.${jQuery}('${hashtag}image-comparison-slider-${id}');
var imagesCompareElement = slider.imagesCompare(settings);
var imagesCompare = imagesCompareElement.data('imagesCompare');
var contentSlider = window.parent.AJS.${jQuery}('${hashtag}content-image-comparison-slider-${id}');

in order to be sure that the DOM is really "ready".

I'm not sure that two bellow encapsulation works as expected...

AJS.toInit(function(){
	$(document).ready(function(){

We plan to switch to version 7 confluence around March or April. Otherwise, we have planned to switch to version 7 confluence around March or April. I could do tests right after.

@v20100v
Copy link
Owner

v20100v commented Jan 10, 2020

I cannot reproduce this bug. Is it possible to take a video capture?

@Crustybat08
Copy link
Author

thanks a lot for your quick answer ! i will see with a programmer if we can add the timeout
And yes i can do a video capture of course

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants