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

make transparency of crop gutters configurable via a slider #4341

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions kahuna/public/js/crop/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,13 @@ crop.controller('ImageCropCtrl', [
}
};

const gutterOpacityCssVarName = "--crop-gutter-opacity";
const rootCss = document.querySelector(':root');
ctrl.gutterTransparency = parseFloat(getComputedStyle(rootCss)?.getPropertyValue(gutterOpacityCssVarName) || "0.5");
ctrl.changeGutterTransparency = (newOpacity) => {
rootCss.style.setProperty(gutterOpacityCssVarName, newOpacity);
};

$scope.$watch('ctrl.cropType', (newCropType, oldCropType) => {
const isCropTypeDisabled = ctrl.cropOptions.find(_ => _.key === newCropType).disabled;

Expand Down
8 changes: 8 additions & 0 deletions kahuna/public/js/crop/view.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@
<div class="warning status--info" ng-if="ctrl.shouldShowVerticalWarningGutters">
Although this is a 5:3 crop, it might be used in a 5:4 space, so please ensure
there is nothing important in the striped sides as these might be clipped.
<div style="display: flex; align-items: center; justify-content: center">
<small>STRIPE TRANSPARENCY</small>
<input type="range" min="0.3" max="1"
ng-model="ctrl.gutterTransparency"
ng-change="ctrl.changeGutterTransparency($event.target.value)"
(input)="ctrl.changeGutterTransparency($event.target.value)"
>
</div>
</div>

<div class="easel" role="main" aria-label="Image cropper"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
background-position: 0 0, 10px 0, 10px -10px, 0px 10px;
}


:root {
--crop-gutter-opacity: 0.5; /* default, set in crop/controller.js based on slider */
}

/* GUTTERS to show what will be clipped if the 5:3 crop is used in 5:4 space */
.easel.vertical-warning-gutters .cropper-view-box::before,
Expand All @@ -54,6 +56,7 @@
top: 0;
bottom: 0;
mix-blend-mode: difference;
opacity: var(--crop-gutter-opacity);
}
.easel.vertical-warning-gutters .cropper-view-box::before { /* left gutter */
left: 0;
Expand All @@ -64,5 +67,5 @@
background: repeating-linear-gradient(45deg, transparent, white 1px, transparent 3px, transparent 6px);
}
.easel.vertical-warning-gutters .easel__canvas {
height: calc(100vh - 115px);
height: calc(100vh - 135px);
}
Loading