Skip to content

Commit

Permalink
[Feat] add setStyle option (#1)
Browse files Browse the repository at this point in the history
* add setStyle

* add missing pkg
  • Loading branch information
BrettCleary authored Aug 27, 2024
1 parent fc79951 commit 84f1ba9
Show file tree
Hide file tree
Showing 3 changed files with 237 additions and 14 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hyperplay/browser-sdk",
"version": "0.0.0",
"version": "0.0.1",
"description": "",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -28,6 +28,7 @@
"license": "UNLICENSED",
"devDependencies": {
"@types/node": "^22.5.0",
"@typescript-eslint/eslint-plugin": "^8.3.0",
"eslint": "^9.9.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
Expand Down
209 changes: 205 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 30 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
export function requestFullscreen(elementId?: string){
window.parent.postMessage({
method: 'requestFullscreen'
}, '*')

if (elementId){
document.getElementById(elementId)?.requestFullscreen()
}
}
export function requestFullscreen({
elementId,
setStyle
}: {
elementId?: string
setStyle?: boolean
}) {
window.parent.postMessage(
{
method: 'requestFullscreen'
},
'*'
)

if (elementId) {
const element = document.getElementById(elementId)
element?.requestFullscreen()
if (setStyle && element) {
element.style.setProperty('position', 'fixed')
element.style.setProperty('top', '0px')
element.style.setProperty('right', '0px')
element.style.setProperty('bottom', '0px')
element.style.setProperty('left', '0px')
element.style.setProperty('width', '100%')
element.style.setProperty('height', '100%')
element.style.setProperty('border', 'none')
element.style.setProperty('overflow', 'hidden')
}
}
}

0 comments on commit 84f1ba9

Please sign in to comment.