Skip to content

Commit 903d4ea

Browse files
Merge pull request #13 from qMRLab/ad/update-chapters
Update the section content
2 parents 1db50ed + 61fa7d0 commit 903d4ea

8 files changed

+1326
-535
lines changed

binder/requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ nibabel
44
pandas
55
plotly
66
scipy
7+
tabulate

content/assets/before_after.css

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
.beforeAfter {
2+
border-radius: 5px;
3+
/* border: 2px solid silver; */
4+
position: relative;
5+
margin: 0;
6+
padding: 0;
7+
}
8+
9+
.after {
10+
height:100%;
11+
width:100%;
12+
z-index: 1;
13+
position: absolute;
14+
}
15+
16+
.before {
17+
height: 100%;
18+
width: 50%;
19+
overflow: hidden;
20+
border-right: 4px solid silver;
21+
z-index: 40;
22+
position: absolute;
23+
}
24+
25+
.middle {
26+
top: 45%;
27+
left: 48%;
28+
z-index: 50;
29+
draggable: true;
30+
position: absolute;
31+
}
32+
33+
.middle:before {
34+
content: '\f1de';
35+
font-family: "Font Awesome 6 Free";
36+
font-size: 30pt;
37+
font-weight: 900;
38+
background-color: silver;
39+
border: 1pt solid black;
40+
cursor: grab;
41+
border-radius: 5pt;
42+
}
43+
44+
.middle:hover:before {
45+
filter: brightness(1.15)
46+
}
47+
48+
.middle:active:before {
49+
cursor: grabbing;
50+
}

content/assets/before_after.js

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
function beforeAfter() {
2+
$(".middle").on("mousedown", function () {
3+
$(document).on("mouseup",function() {
4+
$(document).unbind("mousemove")
5+
$(document).unbind("mouseup")
6+
oldX = undefined
7+
oldY = undefined
8+
})
9+
$(document).on("mousemove", function () {
10+
adjustSize()
11+
})
12+
})
13+
14+
$(".before .modebar").css({'left':'0px', 'position':'absolute'})
15+
}
16+
17+
window.fetch = new Proxy(window.fetch, {
18+
apply(fetch, that, args) {
19+
// Forward function call to the original fetch
20+
const result = fetch.apply(that, args);
21+
22+
// Do whatever you want with the resulting Promise
23+
result.then((response) => {
24+
if (args[0] == '/_dash-update-component') {
25+
setTimeout(function() {beforeAfter()}, 500)
26+
}})
27+
return result
28+
}
29+
}
30+
)
31+
32+
var oldX;
33+
var oldY;
34+
function adjustSize() {
35+
if (event.screenX != 0) {
36+
var clientX = event.clientX
37+
var scrollLeft = $(document).scrollLeft()
38+
39+
if (oldX && !((parseFloat($('.before').css("width"))+((clientX-scrollLeft)-oldX)) > $('.beforeAfter').width())) {
40+
var width = parseFloat($('.before').css("width"))+((clientX-scrollLeft)-oldX)
41+
$('.before').css("width", width)
42+
$('.middle').css("left", ($('.before').width()/$('.beforeAfter').width()*100)-2 + '%')
43+
44+
}
45+
46+
if (parseFloat($('.middle').css('left'))> $('.beforeAfter').width()) {
47+
$('.middle').css("left", '99.5%')
48+
$('.before').css("width", $('.beforeAfter').width())
49+
}
50+
}
51+
oldX = clientX-scrollLeft
52+
event.target.style.cursor = 'grab';
53+
}
54+
55+
$(document).ready(function() {
56+
setTimeout(function() {beforeAfter()}, 1000)
57+
})

0 commit comments

Comments
 (0)