-
Notifications
You must be signed in to change notification settings - Fork 49
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
Advanced screen comparison feature #297
Advanced screen comparison feature #297
Conversation
'use strict'; | ||
angularAMD.directive('aetCompareScreens', compareScreensDirective); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove empty lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for that, they should all be removed by now.
|
||
function linkFunc(scope) { | ||
|
||
scope.advancedScreenComparison = function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a good practice not to keep empty line after function declaration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
var tab = document.querySelector('.test-tabs > .tab-content > .tab-pane.ng-scope.active'); | ||
var wrapper = tab.querySelector('.page-main .layout-compare'); | ||
var initedClass = 'screen-comparison-active'; | ||
var arrangeTimeout; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please assign initial value for this variable, in order to allocate it properly in memory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
var group = []; | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty lines
canvas.canvasWrapper.appendChild(canvas.canvasB); | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty lines
max-width: 48%; | ||
vertical-align: top; | ||
box-sizing: content-box; | ||
&+canvas { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&
is not needed in this case, simple +
will do
@@ -40,19 +40,25 @@ | |||
font-size: 11px; | |||
display: inline-block; | |||
padding: 0 20px; | |||
line-height: 30px; | |||
line-height: 31px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if line-height is declared, you do not need setting height
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest I don't know why this value is even modified. Deleted height value anyway.
@@ -29,6 +29,9 @@ | |||
</label> | |||
</div> | |||
</div> | |||
<div class="try-new button button-small button-blue"> | |||
<a ng-click="advancedScreenComparison()" aet-compare-screens>Advanced Screen Comparison</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use data
prefix for custom attributes- same goes for all directives, it should be data-ng-click
and data-aet-compare-screens
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't know that, thanks. Done now.
} | ||
|
||
function deselectGroups(label, ruler, wrapper) { | ||
label.labelA.style.display = 'none'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider manipulating styles with class on the parent element- otherwise this code will trigger four sequential repaint events (same goes for adding block
display)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed my approach to this one, please take a look and tell me if it's all right now.
var firstGroup = []; | ||
var secondGroup = []; | ||
if (groups[0][0] > 0) { | ||
for (var i = 0; i < groups[0][0]; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you create multiple variable declarations with the same name- in each variable, within the same function scope, they should be unique- think about hoisting ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update CHANGELOG according to AET Contributing rules
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update Layout report documentation with description of this new feature (and maybe one example screenshot?).
@@ -29,6 +29,9 @@ | |||
</label> | |||
</div> | |||
</div> | |||
<div class="try-new button button-small button-blue"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please use more descriptive class name here?
E.g. advanced-screen-comparison
or smth like that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
invertedGroupsB: [], | ||
}; | ||
|
||
var groups = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please make those variables more meaningful?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
imgSizeB: null, | ||
}; | ||
|
||
var simple = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is simple?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
wrapper.classList.add(initedClass); | ||
} | ||
|
||
var button = document.querySelector('.try-new'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please encapsulate logic in the lines below into a function, e.g. markComparisonStarted
or smth. similar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
loadImage(img.imgB, imgSize.imgSizeB, canvas.canvasB, context.contextB, simple.simpleB, function (returnedSimple, returnedImgSize) { | ||
simple.simpleB = returnedSimple; | ||
imgSize.imgSizeB = returnedImgSize; | ||
button.classList.remove('button-disabled'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please encapsulate logic in the lines below into a function, e.g. markComparisonFinished
or smth. similar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've actually left it how it were mainly because I'd need to pass more than 15 parameters to this new function. I might think of something else in the future.
function drawDifferences(difs, imgSize, invertedGroups, simple, context) { | ||
var maxHeight = Math.max(imgSize.imgSizeA.height, imgSize.imgSizeB.height); | ||
var proc = 100 / maxHeight; | ||
var newDiffBLeft = '52%'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this magic number mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the left
value of second canvas' differences that's being created few lines below. I got no idea how to make it clearer, that second canvas just needs to be pushed by 52% from the left to make both canvases apprear next to each other.
…om/m-suchorski/aet into feature/advanced-screen-comparison
More advanced way of comparing screen layouts.
Description
This feature gives user a function to compare screen layouts in more advanced way. User can manually start the comparison.
I've tried to make the original code more readable.
Author: @aux-lux
Motivation and Context
Fixes for this PR: #269
Types of changes
Checklist:
I hereby agree to the terms of the AET Contributor License Agreement.