Skip to content

Commit

Permalink
4.1.17
Browse files Browse the repository at this point in the history
  • Loading branch information
xtiam57 committed Jul 16, 2024
1 parent 332a122 commit da94edf
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 33 deletions.
Binary file not shown.
6 changes: 3 additions & 3 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ <h1 class="display-4 text-light mb-4">Sistema de proyección para Iglesias</h1>



<a href="churchill Setup 4.1.16.exe"
<a href="churchill Setup 4.1.17.exe"
target="_blank"
download="churchill Setup 4.1.16.exe"
download="churchill Setup 4.1.17.exe"
class="button mb-2">Descargar</a>



<small class="text-secondary d-block">v4.1.16</small>
<small class="text-secondary d-block">v4.1.17</small>

<a href="https://github.com/xtiam57/churchill-hymnal-tracks/archive/refs/heads/main.zip"
target="_blank"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "churchill",
"version": "4.1.16",
"version": "4.1.17",
"description": "Sistema de proyección para Iglesias.",
"author": "xtiam57",
"private": true,
Expand Down
7 changes: 0 additions & 7 deletions src/components/presenter/Presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,10 @@ export function Presenter({
}) {
const divRef = useRef(null);
const [divWidth, setDivWidth] = useState(1024);
const [divHeight, setDivHeight] = useState(768);

const handleFontScale = () => {
setTimeout(() => {
resizeText({
key:
castScreen &&
(id.startsWith('A') || id.startsWith('V') || id.startsWith('H'))
? `font-size-${id}-${divWidth}x${divHeight}`
: null,
element: document.getElementById('presenter-html'),
unit: '%',
step: 10,
Expand All @@ -83,7 +77,6 @@ export function Presenter({

useEffect(() => {
setDivWidth(divRef.current.clientWidth);
setDivHeight(divRef.current.clientHeight);
}, []);

useEffect(handleFontScale, []);
Expand Down
40 changes: 18 additions & 22 deletions src/components/presenter/helper.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { Storage } from 'utils';

export function process(text, subtext, book) {
const res = text
.replaceAll('////', '<b>////</b>')
Expand Down Expand Up @@ -30,43 +28,41 @@ const isOverflown = ({ clientHeight, scrollHeight }) => {
};

export const resizeText = ({
key,
element,
minSize = 10,
maxSize = 512,
step = 1,
unit = 'px',
vh = 3.565,
}) => {
if (key) {
const fontSize = Storage.get(key);

if (fontSize) {
element.style.fontSize = `calc(${fontSize}${unit} + ${vh}vh)`;
return;
}
}

element.style.opacity = 0;

let overflow = false;
const parent = element.parentNode;
const array = Array((maxSize - minSize) / step + 1)
.fill(0)
.map((_, i) => i * step + minSize);

let overflow = false;
let min = 0;
let max = array.length - 1;

while (minSize <= maxSize) {
const midSize = Math.floor((minSize + maxSize) / 2);
while (min <= max) {
const midIndex = Math.floor((min + max) / 2);
const testVal = array[midIndex];

element.style.fontSize = `calc(${midSize}${unit} + ${vh}vh)`;
element.style.fontSize = `calc(${testVal}${unit} + ${vh}vh)`;
overflow = isOverflown(parent);

if (!overflow) {
minSize = midSize + step;
min = midIndex + 1;
} else {
maxSize = midSize - step;
max = midIndex - 1;
}
}

// Save the font size to storage
if (key) {
Storage.set(key, maxSize);
}
max = Math.max(0, max);
const value = array[max];

// revert to last state where no overflow happened
element.style.fontSize = `calc(${value}${unit} + ${vh}vh)`;
};

0 comments on commit da94edf

Please sign in to comment.