Skip to content

Commit

Permalink
🎨 Support better aspect ratios #3
Browse files Browse the repository at this point in the history
🐛 Support rotation and flipping of webcam #2
  • Loading branch information
BillyBlaze committed Apr 16, 2017
1 parent 9c84ee7 commit d9bd9d8
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 8 deletions.
67 changes: 65 additions & 2 deletions octoprint_fullscreen/static/css/fullscreen.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,73 @@
img.fullscreen {
.fullscreen {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: black;
z-index: 99;

display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-flex-wrap: nowrap;
-ms-flex-wrap: nowrap;
flex-wrap: nowrap;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-align-content: center;
-ms-flex-line-pack: center;
align-content: center;
-webkit-align-items: center;
-ms-flex-align: center;
}
img.fullscreen + #fullscreen-bar {
.fullscreen img {
width: 100%;
height: auto;
object-fit: contain;
display: block;
max-height: 100%;
max-width: 100%;
}
_:-ms-lang(x), _:-webkit-full-screen, .fullscreen img {
width: auto;
height: 100%;
}
.fullscreen.rotate90 {
-webkit-transform: none;
transform: none;
}
.fullscreen.rotate90 img {
-webkit-transform: rotate(-90deg);
transform: rotate(-90deg);
width: 100vh;
}
.fullscreen.rotate90 img.flipH {
-webkit-transform: rotate(-90deg) scaleX(-1);
-moz-transform: rotate(-90deg) scaleX(-1);
-ms-transform: rotate(-90deg) scaleX(-1);
transform: rotate(-90deg) scaleX(-1);
width: 100vh;
}
.fullscreen.rotate90 img.flipV {
-webkit-transform: rotate(-90deg) scaleY(-1);
-moz-transform: rotate(-90deg) scaleY(-1);
-ms-transform: rotate(-90deg) scaleY(-1);
transform: rotate(-90deg) scaleY(-1);
width: 100vh;
}
.fullscreen.rotate90 img.flipV.flipH {
-webkit-transform: rotate(-90deg) scaleY(-1) scaleX(-1);
-moz-transform: rotate(-90deg) scaleY(-1) scaleX(-1);
-ms-transform: rotate(-90deg) scaleY(-1) scaleX(-1);
transform: rotate(-90deg) scaleY(-1) scaleX(-1);
width: 100vh;
}
.fullscreen + #fullscreen-bar {
display: block;
}
#fullscreen-bar {
Expand Down
11 changes: 6 additions & 5 deletions octoprint_fullscreen/static/js/fullscreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ $(function() {
var self = this;
var $webcam = $('#webcam_image');
var $container = $('#webcam_rotator');
var $fullscreenContainer = $("#webcam_container");
var $info = $('#fullscreen-bar');
var $body = $('body');

Expand All @@ -19,15 +20,15 @@ $(function() {

self.printer.isFullscreen = ko.observable(false);
self.printer.fullscreen = function() {
$container.toggleFullScreen();
$fullscreenContainer.toggleFullScreen();
}

$webcam.on("dblclick", function() {
$body.toggleClass('inlineFullscreen');
$webcam.toggleClass("inline fullscreen");
$container.toggleClass("inline fullscreen");

if(self.printer.isFullscreen()) {
$container.toggleFullScreen();
$fullscreenContainer.toggleFullScreen();
}
});

Expand All @@ -39,7 +40,7 @@ $(function() {
}
});

$info.insertAfter($webcam);
$info.insertAfter($container);
$("#job_pause").clone().appendTo(".user-buttons");

ko.applyBindings(self.printer, document.getElementById("fullscreen-cancel"))
Expand All @@ -52,7 +53,7 @@ $(function() {
]);
});

function formatBarTemperature(toolName, actual, target) {
function formatBarTemperatureFullscreen(toolName, actual, target) {
var output = toolName + ": " + _.sprintf("%.1f°C", actual);

if (target) {
Expand Down
2 changes: 1 addition & 1 deletion octoprint_fullscreen/templates/fullscreen.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
</div>

<script type="text/html" id="tempTemplate">
<span data-bind="html: formatBarTemperature(name(), actual(), target())"></span>
<span data-bind="html: formatBarTemperatureFullscreen(name(), actual(), target())"></span>
</script>

0 comments on commit d9bd9d8

Please sign in to comment.