-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #123 from robitar/122-resize-observer
Add ResizeObserver API
- Loading branch information
Showing
7 changed files
with
155 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
namespace Browser.Types | ||
|
||
open Fable.Core | ||
|
||
type ResizeObserverSize = | ||
abstract inlineSize: float | ||
abstract blockSize: float | ||
|
||
type ResizeObserverEntry = | ||
/// An array containing the new border box sizes of the observed element when the callback is run | ||
abstract borderBoxSize: ResizeObserverSize array | ||
|
||
/// An array containing the new content box sizes of the observed element when the callback is run | ||
abstract contentBoxSize: ResizeObserverSize array | ||
|
||
/// An array containing the new content box sizes in device pixels of the observed element when the callback is run | ||
abstract devicePixelContentBoxSize: ResizeObserverSize array | ||
|
||
/// The new size of the observed element when the callback is run | ||
abstract contentRect: ClientRect | ||
|
||
/// A reference to the Element or SVGElement being observed | ||
abstract target: Node | ||
|
||
[<StringEnum(CaseRules.KebabCase ||| CaseRules.LowerFirst)>] | ||
type ResizeObserverBox = | ||
/// Size of the content area as defined in CSS | ||
| ContentBox | ||
|
||
/// Size of the box border area as defined in CSS | ||
| BorderBox | ||
|
||
/// The size of the content area as defined in CSS, in device pixels, before applying any CSS transforms on the element or its ancestors | ||
| DevicePixelContentBox | ||
|
||
type ResizeObserverOptions = | ||
/// Sets which box model the observer will observe changes to | ||
abstract box: ResizeObserverBox with get, set | ||
|
||
|
||
type [<AllowNullLiteral; Global>] ResizeObserverType = | ||
/// Unobserve all observed Element or SVGElement targets | ||
abstract disconnect: unit -> unit | ||
|
||
/// Starts observing the specified Element or SVGElement | ||
abstract observe: Node -> unit | ||
|
||
/// Starts observing the specified Element or SVGElement with the specified options | ||
abstract observe: Node * ResizeObserverOptions -> unit | ||
|
||
/// Ends the observing of a specified Element or SVGElement | ||
abstract unobserve: Node -> unit | ||
|
||
type ResizeObserverCallback = ResizeObserverEntry array -> ResizeObserverType -> unit | ||
|
||
type [<Global>] ResizeObserverCtor = | ||
[<Emit("new $0($1...)")>] abstract Create: callback: ResizeObserverCallback -> ResizeObserverType | ||
|
||
namespace Browser | ||
|
||
open Fable.Core | ||
open Browser.Types | ||
|
||
[<AutoOpen>] | ||
module ResizeObserver = | ||
let [<Global>] ResizeObserver: ResizeObserverCtor = jsNative |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<PackageId>Fable.Browser.ResizeObserver</PackageId> | ||
<Version>1.0.0</Version> | ||
<PackageVersion>1.0.0</PackageVersion> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
<Tags>fable;fable-binding;fable-javascript</Tags> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="Browser.ResizeObserver.fs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Fable.Core" Version="3.*" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Dom\Browser.Dom.fsproj" /> | ||
</ItemGroup> | ||
<!-- This package doesn't contain actual code so we don't need to add the sources --> | ||
<!-- <ItemGroup> | ||
<Content Include="*.fsproj; *.fs" PackagePath="fable\" /> | ||
</ItemGroup> --> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Browser.ResizeObserver | ||
|
||
Includes bindings for the [Resize Observer API] (https://developer.mozilla.org/en-US/docs/Web/API/Resize_Observer_API) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
### 1.0.0 | ||
|
||
* First release |