@charset "UTF-8";

// @description
// * transition mixin.
// * Apply transition properties with cross-browser compatibility.

// @access public

// @version 1.2.0

// @author Khaled Mohamed

// @license MIT

// @repository: https://github.com/Black-Axis/sass-pire

// @reference: https://developer.mozilla.org/en-US/docs/Web/CSS/transition

// @namespace general

// @module general/transition

// @dependencies:
// * - meta.type-of (SASS function).
// * - var.$time-units (variable).
// * - LibPref.prefixing-all (mixin).
// * - LibFunc1.is-in-list (function).
// * - LibFunc2.cut-unit (function).

// @param {String} $prop
// * The CSS property to apply the transition to. Default: `all`.

// @param {Number} $time
// * The duration of the transition. Default: 0.33ms.

// @param {String} $func
// * The timing function of the transition. Default: `ease-in-out`.

// @param {Number} $delaying
// * The delay before the transition starts. Default: 0ms.

// @example
// * .example {
// *   @include transition(opacity, 0.35s, ease, 1ms);
// * }

// @output
// * .example {
// *   -webkit-transition: opacity 0.35s ease 1ms;
// *   -moz-transition: opacity 0.35s ease 1ms;
// *   -ms-transition: opacity 0.35s ease 1ms;
// *   -o-transition: opacity 0.35s ease 1ms;
// *   transition: opacity 0.35s ease 1ms;
// * }

// stylelint-disable scss/dollar-variable-empty-line-before

@use "sass:meta";
@use "sass:list";
@use "sass:math";
@use "../../abstract/global-variables" as var;
@use "..//vendor-prefixes/prefix" as LibPref;
@use "../../functions/global/is-in-list" as LibFunc1;
@use "../../functions/global/cut-unit" as LibFunc2;
@use "../../development-utils/toggle-error-message" as Error;

@mixin transition($prop: all, $time: 0.33ms, $func: ease-in-out, $delaying: 0ms) {
    $time-unit: math.unit($time);
    $delaying-unit: math.unit($delaying);
    $params-with-types-map: (
        $prop: "string",
        $time: "number",
        $func: "string",
        $delaying: "number"
    );

    $transitions-function-values: (ease, ease-in, ease-in-out, linear) !default;
    $list-transition-functions: (ease, ease-in, ease-in-out, linear) !default;

    @if LibFunc1.is-in-list($list-transition-functions, $func) and
        LibFunc1.is-in-list(var.$time-units, $time-unit) and
        LibFunc1.is-in-list(var.$time-units, $delaying-unit)
    {
        @each $custom, $val in $params-with-types-map {
            @if meta.type-of($custom) != $val {
                content: Error.throw("#{$custom} parameter must be in type #{$val}.");
            }
        }
        
        @if $time < 0 {
            content: Error.throw("Time of transition must be equal or bigger than zero.");
        }
        
        @if $delaying < 0 {
            content: Error.throw("Transition delay must be equal or bigger than zero.");
        }

        @if LibFunc2.cut-unit($delaying) == 0 {
            @include LibPref.prefixing-all(transition, $prop #{$time} #{$func} #{LibFunc2.cut-unit($delaying)});
        } @else {
            @include LibPref.prefixing-all(transition, $prop #{$time} #{$func} #{$delaying});
        }
    }
}
