Browse Source

fix(style): youtube iframe width on mobile

Tienson Qin 5 years ago
parent
commit
1b304b15ac
1 changed files with 11 additions and 8 deletions
  1. 11 8
      src/main/frontend/components/block.cljs

+ 11 - 8
src/main/frontend/components/block.cljs

@@ -666,14 +666,17 @@
                                   :else
                                   nil)]
             (when-not (string/blank? youtube-id)
-              [:iframe
-               {:allow-full-screen "allowfullscreen"
-                :allow
-                "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
-                :frame-border "0"
-                :src (str "https://www.youtube.com/embed/" youtube-id)
-                :height "315"
-                :width "560"}])))
+              (let [width (min (- (util/get-width) 96)
+                               560)
+                    height (int (* width (/ 315 560)))]
+                [:iframe
+                 {:allow-full-screen "allowfullscreen"
+                  :allow
+                  "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
+                  :frame-border "0"
+                  :src (str "https://www.youtube.com/embed/" youtube-id)
+                  :height height
+                  :width width}]))))
 
         (= name "embed")
         (let [a (first arguments)]