all files / action/ transform.js

91.79% Statements 1464/1595
80.26% Branches 817/1018
98.21% Functions 55/56
91.84% Lines 1464/1594
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217   324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324×   616× 308×   308×   324× 324×   308× 308×   86917× 86917×   20× 20×   8353× 8353×   334× 334×   241× 241×     264× 264×   84× 84×   48× 48×   53× 53×   47× 47×   39× 39×   2061× 2061×   146× 146×   4722× 4722×   338× 338×   218× 218×   343× 343×   23254× 23254×   19× 19×   14× 14×     129× 129×   16986× 16986×     136× 136× 136× 136×   16971× 16971×   74× 74×   30× 30×   8927× 8927×   386× 386×   692× 692×   917× 917× 917×   40× 40×   80× 80×   25× 25×   16× 16×   24× 24×   40× 40×   11× 11×   431× 431×   391× 391×       6550×   86917× 86917×   86917× 86917×     431× 431× 431× 431× 431× 431× 431× 431× 431× 431× 431×   345× 345×   345× 219× 219×   345×   345× 345× 344× 344× 322× 322× 322× 322× 322× 322× 322× 322× 322×   344× 344× 344× 344× 75× 75×   75× 74× 74× 74× 74×     344×   344× 344× 344× 344× 344× 344× 11×     344× 74× 74× 74× 74×   344× 344× 344×   344× 344× 29× 29× 29×   29× 29× 29×           344× 344×     342×   344× 16×   344× 344× 344× 344× 344× 344× 344×     344× 344× 344×   344×   344× 344× 344× 11×     344× 344× 344× 267×     77× 231×     344×   344×   344× 344× 344× 344× 344× 344× 344× 344× 344× 344× 344× 344× 344×   564× 564× 169× 169× 169×   169×   169× 169× 169×     169× 125× 125×     169× 169× 169×   169× 169× 169×       221× 221×   221× 176× 176×   221×   221× 221×   220× 220× 203× 203× 203× 203× 203× 203× 203× 203×   203×   220× 220× 220× 220× 219× 34×   219× 34× 34× 34× 34×     220×   220× 220× 220× 220× 220× 220× 220× 220×     220× 220× 220× 220×   220× 220× 220× 25× 25×   220× 220× 220× 220× 220× 220× 220×   220× 220×   220× 61× 61×   61×         61×     220×     220× 220× 220× 232× 232× 140×   92× 31×     61×     220× 220× 220×   220× 220× 220× 220×   220×             220× 220× 220× 220× 220× 220× 220×     220× 34× 34× 34× 34×   220× 220×   220× 220× 24× 24× 24×   24× 24× 24×     440× 440× 270× 98×     172×     170× 170× 70×     100×       242× 242× 242× 242×   198× 198× 198× 198×   220× 45×   175× 162×     13×   175×             8554× 8554× 8554× 8554× 8554×   8554× 805× 423×   382× 239×     143× 143×       1924× 1924× 1922×       1920× 1920× 1920× 1920× 673× 126×   547× 409×   138× 138× 138× 138×     1920× 1920× 1920× 1920× 1920× 1920× 70×       70×     1920× 68× 68×   1852×       1920× 1920× 1920× 1920× 68×       1852×   1920×       1920× 1920×   1920× 121× 121×   1920×     1920× 1920× 1920× 1920×   1919×   1919×   1919×   1919× 1919× 1919× 1919× 1919× 1919× 1919× 1791× 427× 427× 427× 427× 427× 427×   1364× 36×   1791× 1770×     1919× 1439× 1439× 1439× 1439× 52× 52× 52× 52× 52× 52× 52× 52× 52× 52× 52×   52× 52×     1439× 1178×       480× 443×   480× 480× 480× 480× 480× 480× 53× 53× 53×   53×     1919× 1919×   1631× 1631×   1919× 1919× 1919× 1814× 1814× 1814×   1814×   1919× 50×     1919× 1919× 1919× 68× 68× 68× 34×     1919× 1919× 1919× 1919× 233× 233×   1686× 173× 173×   1919× 1919× 1919× 1919× 68×   1919× 60×   1919×                   1919× 1919× 1919× 1919× 120×   1919×                                             1916×           377× 377× 377× 377× 377× 377×   377× 377×   377× 195× 195× 195× 170×       160×     10×       25× 25× 25× 25× 25× 25×   18×         195× 195× 178× 178×     17× 17×         182×   377× 377×   377× 377× 377× 377× 377×   1439× 1439× 1439× 1439× 33×     1406×   1439× 1439× 1439× 75×     1364× 1364× 1364× 1364× 1364×   1439× 1439× 1439× 1439× 1439× 1439×   54× 54× 54× 54× 54× 54× 54× 54× 54× 54×   54× 54× 54× 54×   54×     54× 54× 54× 54× 54× 54× 54×     54×   480× 480× 480× 480× 44×     436×   480× 53×     427×   480× 480× 480× 480× 480×   480× 480× 480× 480× 480× 480× 480×   480× 480× 480× 480× 480× 480×   1919× 1919× 555× 555× 555× 555×     1364×     466× 466× 466× 466× 466×       466×   466× 466× 466× 466× 466× 466× 466× 14×           14×           14×           14×             466×   377× 377× 377× 377× 107×     270×   377× 377× 377× 377× 377× 195× 195× 195× 195× 195× 195× 195× 124×   195× 130×   195× 124×   195× 130×     182× 182× 179×   182× 145×   182× 179×   182× 146×     377×   264× 264× 264× 264× 264× 264×     264×   265× 265× 265×     265× 76× 76×   76× 76× 76× 76× 76×     76×   76×     76×   76× 76× 76× 76× 76× 76× 76×   76×   265×                   261× 261× 261×                 261×   261× 261× 261× 261×   265× 76× 76× 76×     88× 88× 88×   88× 88×   88× 88× 88× 88× 88× 88×   88× 88×   88×       88× 88×   88× 88× 88× 88× 88× 88× 88×   88×     88×   88× 88× 88×         87× 87× 33× 33× 33× 33× 33× 33× 33× 33× 33×   33× 33× 33× 33× 24×       33× 33×     48× 48× 48× 48× 24× 12× 12×   12× 12×           101×     46× 46×   35× 35×   12× 12×     736× 736× 736× 736× 736× 736× 292×   736× 736× 736× 736× 736× 736× 736× 736× 736× 736× 736×   736× 736× 736× 736× 293× 293×   736× 736× 293× 293×   736× 736× 73×   736× 736× 73×   736× 736×   736× 736× 736× 736× 736× 736× 736× 736× 736× 736× 736× 736×   736× 736× 736× 427× 427× 427× 427× 427× 427× 427×           736× 73×   736×     736× 73×   736× 736× 736× 736× 736× 292×     736×                   2061× 2061× 2061× 1369× 1369×   1369× 1369× 1369× 1369×           692× 692× 692×       146× 146× 130× 130× 114×     16× 16× 16×       130×   130×     130×     4722× 4722× 4137×   585× 286×     299× 115×       184×   4722×   338× 338× 338× 291×   338×   218× 218× 154×     343× 343× 343× 343× 343× 343× 343× 343× 343× 343× 22× 22× 22×                     22× 22× 22×       22× 22×   22× 22×             343× 343× 343× 343× 343×   343× 343×   342× 341× 341×     343× 343×     343× 343×           343× 343×     343× 343×     343× 343× 343× 343× 343× 343× 22× 22× 22× 22× 22× 22× 22× 22×   22× 22× 22× 22× 22× 22× 22× 22×       22×     22×   22×   22× 22× 22× 22× 22× 22×   18×   22× 22× 22× 19×   19×           22×   22× 22× 22×       22× 22× 22× 22× 22× 22× 22× 22×   22× 17×     22× 22× 22×               22×   22×       22×         20×       25483× 25483× 25483× 25483× 25483× 25483× 25483× 25483× 25483×       25483×     25483× 25483× 24997× 24997×   24997× 24133×     25483× 25483× 25483× 25483× 25483× 61× 61×   25422× 19957× 19957×   25483× 25468× 25468×   25468×           25483× 23276× 23276×   25483×                                                             25× 25× 25× 25× 25× 25× 25× 25× 25× 25× 25× 25× 25× 25× 25×   25× 34× 34× 25× 549× 549× 549×       25×                   25× 25× 25× 549× 549× 549× 532× 532×     25× 12× 12×   25×       25× 25× 25× 25× 25× 25×       25×   16× 16× 16× 16× 16× 16× 16× 16× 16× 16× 16× 16× 16×   16× 16×   16× 16× 16× 16× 14× 14×         14×         13× 56×     17×   29× 29×                               16×     16× 16× 16× 16× 16× 500× 500×   16× 12× 12×     16× 16× 110× 110×   16×     16× 16× 16× 16× 16× 16× 16×   16× 16× 16× 16×   12× 12× 12×     16× 12× 12×               16× 16× 16× 16× 16× 16×               16× 16× 16× 16×   16× 16×           16× 16× 16×   24× 24× 24× 24× 24× 24×   24× 24× 24× 24× 24×   24× 24×     40× 40× 40× 40×     40× 40× 40×           40× 40× 38×       40×       40× 40× 40× 40×             40× 40× 40× 40× 40× 25× 10× 10×   25× 10× 10× 10× 10× 10×           15×       15×       15×                             15×     40×   11× 11× 11×       11× 11× 11× 11×          
define(["require", "exports", "@syncfusion/ej2-base", "../index", "@syncfusion/ej2-popups"], function (require, exports, ej2_base_1, index_1, ej2_popups_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var Transform = (function () {
        function Transform(parent) {
            this.isReverseFlip = false;
            this.disablePan = false;
            this.isReverseRotate = false;
            this.flipColl = [];
            this.prevZoomValue = 1;
            this.cropDimension = { width: 0, height: 0 };
            this.isPreventSelect = false;
            this.preventDownScale = false;
            this.resizedImgAngle = null;
            this.parent = parent;
            this.addEventListener();
        }
        Transform.prototype.destroy = function () {
            if (this.parent.isDestroyed) {
                return;
            }
            this.removeEventListener();
        };
        Transform.prototype.addEventListener = function () {
            this.parent.on('transform', this.transform, this);
            this.parent.on('destroyed', this.destroy, this);
        };
        Transform.prototype.removeEventListener = function () {
            this.parent.off('transform', this.transform);
            this.parent.off('destroyed', this.destroy);
        };
        Transform.prototype.transform = function (args) {
            this.initTransformPvtVar();
            switch (args.prop) {
                case 'flipImage':
                    this.flipImage(args.value['direction']);
                    break;
                case 'setDestPointsForFlipState':
                    this.setDestPointsForFlipState();
                    break;
                case 'zoomAction':
                    this.zoomAction(args.value['zoomFactor'], args.value['zoomPoint'], args.value['isResize']);
                    break;
                case 'disableZoomOutBtn':
                    this.disableZoomOutBtn(args.value['isZoomOut']);
                    break;
                case 'rotatedFlip':
                    this.rotatedFlip();
                    break;
                case 'drawPannedImage':
                    this.drawPannedImage(args.value['xDiff'], args.value['yDiff']);
                    break;
                case 'drawPannImage':
                    this.drawPannImage(args.value['point']);
                    break;
                case 'performTransformation':
                    this.performTransformation(args.value['text']);
                    break;
                case 'updateTransform':
                    this.updateTransform(args.value['text']);
                    break;
                case 'rotatePan':
                    this.rotatePan(args.value['isCropSelection'], args.value['isDefaultZoom']);
                    break;
                case 'resetZoom':
                    this.resetZoom();
                    break;
                case 'pan':
                    this.pan(args.value['value'], args.value['x'], args.value['y']);
                    break;
                case 'zoom':
                    this.zoom(args.value['zoomFactor'], args.value['zoomPoint']);
                    break;
                case 'setCurrPanRegion':
                    this.setCurrPanRegion(args.value['region'], args.value['type'], args.value['obj']);
                    break;
                case 'rotate':
                    this.rotate(args.value['degree'], args.value['obj']);
                    break;
                case 'flip':
                    this.flip(args.value['direction']);
                    break;
                case 'update':
                    this.update();
                    break;
                case 'calcMaxDimension':
                    this.calcMaxDimension(args.value['width'], args.value['height'], args.value['obj'], args.value['isImgShape']);
                    break;
                case 'getPanMove':
                    args.value['obj']['panMove'] = this.panMove;
                    break;
                case 'setPanMove':
                    this.panMove = args.value['point'];
                    break;
                case 'getTempPanMove':
                    args.value['obj']['tempPanMove'] = this.tempPanMove;
                    break;
                case 'setTempPanMove':
                    this.tempPanMove = args.value['point'];
                    break;
                case 'setReverseFlip':
                    this.isReverseFlip = args.value['isReverseFlip'];
                    break;
                case 'setDisablePan':
                    this.disablePan = args.value['bool'];
                    break;
                case 'setCurrDestinationPoint':
                    this.currDestPoint = args.value['point'];
                    this.currDestPoint.startX -= this.parent.cropObj.totalPannedPoint.x;
                    this.currDestPoint.startY -= this.parent.cropObj.totalPannedPoint.y;
                    break;
                case 'setReverseRotate':
                    this.isReverseRotate = args.value['bool'];
                    break;
                case 'getFlipColl':
                    args.value['obj']['flipColl'] = this.flipColl;
                    break;
                case 'setFlipColl':
                    this.flipColl = args.value['flipColl'];
                    break;
                case 'getPreviousZoomValue':
                    args.value['obj']['previousZoomValue'] = this.prevZoomValue;
                    break;
                case 'setPreviousZoomValue':
                    this.prevZoomValue = args.value['previousZoomValue'];
                    break;
                case 'getCropDimension':
                    args.value['obj']['cropDimension'] = this.cropDimension;
                    break;
                case 'setCropDimension':
                    this.cropDimension.width = args.value['width'];
                    this.cropDimension.height = args.value['height'];
                    break;
                case 'getPreventSelect':
                    args.value['obj']['bool'] = this.isPreventSelect;
                    break;
                case 'setPreventSelect':
                    this.isPreventSelect = args.value['bool'];
                    break;
                case 'resizeImage':
                    this.resizeImage(args.value['width'], args.value['height']);
                    break;
                case 'resizeCrop':
                    this.resizeCrop(args.value['width'], args.value['height']);
                    break;
                case 'updateResize':
                    this.updateResize();
                    break;
                case 'resize':
                    this.resize(args.value['width'], args.value['height'], args.value['isAspectRatio']);
                    break;
                case 'straightenImage':
                    this.straightenImage(args.value['degree']);
                    break;
                case 'reset':
                    this.reset();
                    break;
                case 'cropZoom':
                    args.value['obj']['maxDimension'] = this.cropZoom(args.value['value'], args.value['selectionObj']);
                    break;
                case 'setResizedImgAngle':
                    this.resizedImgAngle = args.value['angle'];
                    break;
            }
        };
        Transform.prototype.getModuleName = function () {
            return 'transform';
        };
        Transform.prototype.initTransformPvtVar = function () {
            Eif (this.parent.lowerCanvas) {
                this.lowerContext = this.parent.lowerCanvas.getContext('2d');
            }
            Eif (this.parent.upperCanvas) {
                this.upperContext = this.parent.upperCanvas.getContext('2d');
            }
        };
        Transform.prototype.reset = function () {
            this.zoomBtnHold = null;
            this.tempPanMove = null;
            this.panMove = null;
            this.disablePan = false;
            this.currDestPoint = null;
            this.isReverseRotate = false;
            this.flipColl = [];
            this.resizedImgAngle = null;
            this.transCurrObj = null;
            this.prevZoomValue = 1;
            this.isPreventSelect = this.preventDownScale = false;
        };
        Transform.prototype.rotateImage = function (degree) {
            var parent = this.parent;
            var transitionArgs = { cancel: false, previousDegree: parent.transform.degree,
                currentDegree: Math.abs(parent.transform.degree + degree) === 360 ? 0 : parent.transform.degree + degree };
            if (!this.isPreventSelect) {
                parent.trigger('rotating', transitionArgs);
                parent.editCompleteArgs = transitionArgs;
            }
            this.rotateEvent(transitionArgs, degree);
        };
        Transform.prototype.rotateEvent = function (transitionArgs, degree) {
            var parent = this.parent;
            if (!transitionArgs.cancel) {
                var prevObj = void 0;
                if (ej2_base_1.isNullOrUndefined(this.transCurrObj)) {
                    var object = { currObj: {} };
                    parent.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
                    prevObj = object['currObj'];
                    prevObj.objColl = ej2_base_1.extend([], parent.objColl, null, true);
                    prevObj.pointColl = ej2_base_1.extend({}, parent.pointColl, null, true);
                    prevObj.afterCropActions = ej2_base_1.extend([], parent.afterCropActions, [], true);
                    var selPointCollObj = { selPointColl: null };
                    parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false, value: { obj: selPointCollObj } });
                    prevObj.selPointColl = ej2_base_1.extend([], selPointCollObj['selPointColl'], [], true);
                }
                parent.afterCropActions.push(degree === 90 ? 'rotateRight' : 'rotateLeft');
                var splitWords = [];
                var activeObjShape = void 0;
                if (parent.activeObj.activePoint && parent.activeObj.shape) {
                    Eif (parent.activeObj.shape !== undefined) {
                        splitWords = parent.activeObj.shape.split('-');
                    }
                    if (parent.currObjType.isCustomCrop || splitWords[0] === 'crop') {
                        activeObjShape = parent.currObjType.isCustomCrop ? 'custom' : splitWords[1];
                        parent.notify('shape', { prop: 'updImgRatioForActObj', onPropertyChange: false });
                        parent.objColl.push(parent.activeObj);
                        parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
                    }
                }
                parent.notify('shape', { prop: 'redrawActObj', onPropertyChange: false,
                    value: { x: null, y: null, isMouseDown: true } });
                this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
                this.drawRotatedImage(degree);
                parent.notify('draw', { prop: 'setImageEdited', onPropertyChange: false });
                parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.lowerContext } });
                parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.upperContext } });
                if (parent.isCircleCrop) {
                    parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
                        value: { context: this.lowerContext, isSave: null, isFlip: null } });
                }
                if (activeObjShape) {
                    this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
                    parent.activeObj = ej2_base_1.extend({}, parent.objColl[parent.objColl.length - 1], {}, true);
                    parent.objColl.pop();
                    parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: parent.activeObj } });
                }
                parent.isUndoRedo = false;
                var obj = { collection: parent.rotateFlipColl };
                parent.notify('shape', { prop: 'alignRotateFlipColl', onPropertyChange: false,
                    value: { collection: parent.rotateFlipColl, isRotateFlipCollection: true, obj: obj } });
                parent.rotateFlipColl = obj['collection'];
                if (parent.cropObj.activeObj.shape && !this.isPreventSelect) {
                    parent.notify('draw', { prop: 'setIsCropSelect', value: { bool: true } });
                    this.isPreventSelect = true;
                    parent.notify('draw', { prop: 'select', onPropertyChange: false,
                        value: { type: 'custom', startX: null, startY: null, width: null, height: null } });
                    this.isPreventSelect = false;
                    parent.setProperties({ zoomSettings: { zoomFactor: 1 } }, true);
                    this.prevZoomValue = parent.zoomSettings.zoomFactor;
                }
            }
            else {
                parent.notify('draw', { prop: 'setCurrentObj', onPropertyChange: false, value: { obj: parent.prevEventObjPoint } });
                parent.activeObj = parent.prevEventSelectionPoint;
                parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: parent.activeObj } });
            }
        };
        Transform.prototype.drawRotatedImage = function (degree) {
            var parent = this.parent;
            if (degree === 0) {
                parent.transform.degree = 0;
            }
            else {
                parent.transform.degree += degree;
            }
            if (Math.abs(parent.transform.degree) === 360) {
                parent.transform.degree = 0;
            }
            parent.notify('draw', { prop: 'setDestPoints', onPropertyChange: false });
            var tempObjColl = ej2_base_1.extend([], parent.objColl, [], true);
            var tempActiveObj = ej2_base_1.extend({}, parent.activeObj, {}, true);
            parent.objColl = [];
            parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
            Eif (!this.isReverseRotate) {
                parent.notify('draw', { prop: 'updateCurrTransState', onPropertyChange: false,
                    value: { type: 'initial', isPreventDestination: null, isRotatePan: null } });
            }
            this.rotateDegree(degree);
            Eif (!this.isReverseRotate) {
                parent.notify('draw', { prop: 'updateCurrTransState', onPropertyChange: false,
                    value: { type: 'reverse', isPreventDestination: null, isRotatePan: null } });
                parent.rotateFlipColl.push(degree);
            }
            parent.objColl = ej2_base_1.extend([], tempObjColl, [], true);
            parent.activeObj = ej2_base_1.extend({}, tempActiveObj, {}, true);
            if (parent.isCircleCrop) {
                parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
                    value: { context: this.lowerContext, isSave: null, isFlip: null } });
            }
            parent.notify('shape', { prop: 'redrawObj', onPropertyChange: false, value: { degree: degree } });
            parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
            if (degree > 0) {
                parent.notify('freehand-draw', { prop: 'rotateFhdColl', onPropertyChange: false });
            }
            else {
                for (var i = 0; i < 3; i++) {
                    parent.notify('freehand-draw', { prop: 'rotateFhdColl', onPropertyChange: false });
                }
            }
            parent.notify('freehand-draw', { prop: 'freehandRedraw', onPropertyChange: false,
                value: { context: this.lowerContext, points: null } });
            this.updateCurrSelectionPoint(degree);
        };
        Transform.prototype.rotateDegree = function (degree) {
            var parent = this.parent;
            this.lowerContext.save();
            this.lowerContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
            this.lowerContext.translate(parent.lowerCanvas.width / 2, parent.lowerCanvas.height / 2);
            this.lowerContext.rotate(Math.PI / 180 * degree);
            this.lowerContext.translate(-parent.lowerCanvas.width / 2, -parent.lowerCanvas.height / 2);
            var temp = this.lowerContext.filter;
            parent.notify('draw', { prop: 'drawImage', onPropertyChange: false });
            this.lowerContext.filter = temp;
            this.lowerContext.translate(parent.lowerCanvas.width / 2, parent.lowerCanvas.height / 2);
            this.lowerContext.rotate(Math.PI / 180 * -degree);
            this.lowerContext.translate(-parent.lowerCanvas.width / 2, -parent.lowerCanvas.height / 2);
            this.lowerContext.restore();
        };
        Transform.prototype.updateCurrSelectionPoint = function (degree) {
            var parent = this.parent;
            if (parent.currSelectionPoint && this.currDestPoint) {
                var activeObj = ej2_base_1.extend({}, parent.activeObj, {}, true);
                var objColl = ej2_base_1.extend([], parent.objColl, [], true);
                var srcPoints = { startX: parent.img.srcLeft, startY: parent.img.srcTop, width: parent.img.srcWidth,
                    height: parent.img.srcHeight };
                var destPoints = { startX: parent.img.destLeft, startY: parent.img.destTop, width: parent.img.destWidth,
                    height: parent.img.destHeight };
                parent.objColl = [];
                parent.objColl.push(ej2_base_1.extend({}, parent.currSelectionPoint, {}, true));
                parent.img = { srcLeft: 0, srcTop: 0, srcWidth: parent.baseImgCanvas.width, srcHeight: parent.baseImgCanvas.height,
                    destLeft: this.currDestPoint.startX, destTop: this.currDestPoint.startY, destWidth: this.currDestPoint.width,
                    destHeight: this.currDestPoint.height };
                if (typeof (degree) === 'number') {
                    parent.notify('draw', { prop: 'setDestPoints', onPropertyChange: false });
                    parent.notify('draw', { prop: 'setClientTransDim', onPropertyChange: false,
                        value: { isPreventDimension: null } });
                }
                parent.notify('shape', { prop: 'redrawObj', onPropertyChange: false, value: { degree: degree } });
                parent.currSelectionPoint = ej2_base_1.extend({}, parent.objColl[0], {}, true);
                this.currDestPoint = { startX: parent.img.destLeft, startY: parent.img.destTop, width: parent.img.destWidth,
                    height: parent.img.destHeight };
                parent.objColl = objColl;
                parent.activeObj = activeObj;
                parent.img = { srcLeft: srcPoints.startX, srcTop: srcPoints.startY, srcWidth: srcPoints.width, srcHeight: srcPoints.height,
                    destLeft: destPoints.startX, destTop: destPoints.startY, destWidth: destPoints.width, destHeight: destPoints.height };
            }
        };
        Transform.prototype.flipImage = function (direction) {
            var parent = this.parent;
            var transitionArgs = { direction: direction, cancel: false,
                previousDirection: parent.toPascalCase(parent.transform.currFlipState || direction) };
            if (!this.isPreventSelect) {
                parent.trigger('flipping', transitionArgs);
                parent.editCompleteArgs = transitionArgs;
            }
            this.flipEvent(transitionArgs, direction);
        };
        Transform.prototype.flipEvent = function (transitionArgs, direction) {
            var parent = this.parent;
            if (transitionArgs.cancel) {
                parent.notify('draw', { prop: 'setCurrentObj', onPropertyChange: false, value: { obj: parent.prevEventObjPoint } });
                parent.activeObj = parent.prevEventSelectionPoint;
                parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: parent.activeObj } });
                return;
            }
            var prevObj;
            if (ej2_base_1.isNullOrUndefined(this.transCurrObj)) {
                var object = { currObj: {} };
                parent.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
                prevObj = object['currObj'];
                prevObj.objColl = ej2_base_1.extend([], parent.objColl, null, true);
                prevObj.pointColl = ej2_base_1.extend({}, parent.pointColl, null, true);
                prevObj.afterCropActions = ej2_base_1.extend([], parent.afterCropActions, [], true);
                var selPointCollObj = { selPointColl: null };
                parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
                    value: { obj: selPointCollObj } });
                prevObj.selPointColl = ej2_base_1.extend([], selPointCollObj['selPointColl'], [], true);
            }
            parent.afterCropActions.push(direction.toLowerCase() === 'horizontal' ? 'horizontalflip' : 'verticalflip');
            var splitWords = [];
            var activeObjShape;
            if (parent.activeObj.activePoint) {
                if (parent.activeObj.shape !== undefined) {
                    splitWords = parent.activeObj.shape.split('-');
                }
                if (parent.currObjType.isCustomCrop || splitWords[0] === 'crop') {
                    activeObjShape = parent.currObjType.isCustomCrop ? 'custom' : splitWords[1];
                    parent.notify('shape', { prop: 'updImgRatioForActObj', onPropertyChange: false });
                    parent.objColl.push(parent.activeObj);
                    parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
                }
            }
            parent.notify('shape', { prop: 'redrawActObj', onPropertyChange: false,
                value: { x: null, y: null, isMouseDown: true } });
            parent.clearContext(this.lowerContext);
            parent.clearContext(this.upperContext);
            var tempObjColl = ej2_base_1.extend([], parent.objColl, [], true);
            var tempActiveObj = ej2_base_1.extend({}, parent.activeObj, {}, true);
            parent.objColl = [];
            parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
            Eif (!this.isReverseFlip) {
                parent.notify('draw', { prop: 'updateCurrTransState', onPropertyChange: false,
                    value: { type: 'initial', isPreventDestination: null, isRotatePan: null } });
            }
            var lowercaseDirection = direction.toLowerCase();
            this.updateFlipState(lowercaseDirection);
            var flipState = parent.transform.currFlipState.toLowerCase();
            parent.transform.currFlipState = (lowercaseDirection === 'horizontal' && flipState === 'horizontal') ||
                (lowercaseDirection === 'vertical' && flipState === 'vertical') ? '' : lowercaseDirection;
            var selObj = { isSelected: null };
            parent.notify('draw', { prop: 'getRotatedFlipCropSelection', onPropertyChange: false, value: { bool: selObj } });
            if (selObj['isSelected']) {
                parent.img.destLeft += parent.panPoint.totalPannedInternalPoint.x;
                parent.img.destTop += parent.panPoint.totalPannedInternalPoint.y;
            }
            var temp = this.lowerContext.filter;
            parent.notify('draw', { prop: 'drawImage', onPropertyChange: false });
            this.lowerContext.filter = temp;
            parent.notify('draw', { prop: 'setImageEdited', onPropertyChange: false });
            this.updateFlipState(direction.toLowerCase());
            Eif (!this.isReverseFlip) {
                parent.notify('draw', { prop: 'updateCurrTransState', onPropertyChange: false,
                    value: { type: 'reverse', isPreventDestination: null, isRotatePan: null } });
                this.updateFlipColl(direction.toLocaleLowerCase());
                parent.rotateFlipColl.push(direction.toLowerCase());
            }
            if (parent.rotateFlipColl.length === 1) {
                var panObj = { panRegion: '' };
                parent.notify('crop', { prop: 'getCurrFlipState', onPropertyChange: false,
                    value: { panObj: panObj } });
                Iif (panObj['panRegion'] === '') {
                    parent.notify('draw', { prop: 'setClientTransDim', onPropertyChange: false,
                        value: { isPreventDimension: null } });
                }
                else {
                    this.setDestPointsForFlipState();
                }
            }
            if (parent.isCircleCrop) {
                parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
                    value: { context: this.lowerContext, isSave: null, isFlip: null } });
            }
            parent.objColl = ej2_base_1.extend([], tempObjColl, [], true);
            parent.activeObj = ej2_base_1.extend({}, tempActiveObj, {}, true);
            for (var i = 0, len = parent.objColl.length; i < len; i++) {
                var flipObjColl = parent.objColl[i].flipObjColl;
                if (flipObjColl.length === 0) {
                    flipObjColl.push(direction);
                }
                else if (flipObjColl[flipObjColl.length - 1] === direction) {
                    flipObjColl.pop();
                }
                else {
                    flipObjColl.push(direction);
                }
            }
            parent.notify('shape', { prop: 'redrawObj', onPropertyChange: false, value: { degree: direction.toLowerCase() } });
            var tempFilter = this.lowerContext.filter;
            this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
                'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
            parent.notify('shape', { prop: 'iterateObjColl', onPropertyChange: false });
            var dir = direction.toLowerCase();
            Eif (dir === 'horizontal' || dir === 'vertical') {
                parent.notify('freehand-draw', { prop: 'flipFHDColl', onPropertyChange: false,
                    value: { value: dir } });
                parent.notify('freehand-draw', { prop: 'freehandRedraw', onPropertyChange: false,
                    value: { context: this.lowerContext, points: null } });
            }
            else {
                parent.notify('freehand-draw', { prop: 'freehandRedraw', onPropertyChange: false,
                    value: { context: this.lowerContext, points: null } });
            }
            this.lowerContext.filter = tempFilter;
            parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
            this.updateCurrSelectionPoint(dir);
            parent.isUndoRedo = false;
            parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.lowerContext } });
            parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.upperContext } });
            if (parent.isCircleCrop) {
                parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
                    value: { context: this.lowerContext, isSave: null, isFlip: null } });
            }
            if (activeObjShape) {
                this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
                parent.activeObj = ej2_base_1.extend({}, parent.objColl[parent.objColl.length - 1], {}, true);
                parent.objColl.pop();
                parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: parent.activeObj } });
            }
            var obj = { collection: parent.rotateFlipColl };
            parent.notify('shape', { prop: 'alignRotateFlipColl', onPropertyChange: false,
                value: { collection: parent.rotateFlipColl, isRotateFlipCollection: true, obj: obj } });
            parent.rotateFlipColl = obj['collection'];
            if (parent.cropObj.activeObj.shape && !this.isPreventSelect) {
                parent.notify('draw', { prop: 'setIsCropSelect', value: { bool: true } });
                this.isPreventSelect = true;
                parent.notify('draw', { prop: 'select', onPropertyChange: false,
                    value: { type: 'custom', startX: null, startY: null, width: null, height: null } });
                this.isPreventSelect = false;
                parent.setProperties({ zoomSettings: { zoomFactor: 1 } }, true);
                this.prevZoomValue = parent.zoomSettings.zoomFactor;
            }
        };
        Transform.prototype.updateFlipState = function (direction) {
            var degree = this.parent.transform.degree;
            if (direction === 'horizontal') {
                if (degree % 90 === 0 && degree % 180 !== 0) {
                    this.verticalFlip();
                }
                else {
                    this.horizontalFlip();
                }
            }
            else Eif (direction === 'vertical') {
                if (degree % 90 === 0 && degree % 180 !== 0) {
                    this.horizontalFlip();
                }
                else {
                    this.verticalFlip();
                }
            }
        };
        Transform.prototype.horizontalFlip = function () {
            this.lowerContext.translate(this.lowerContext.canvas.width, 0);
            this.lowerContext.scale(-1, 1);
            this.upperContext.translate(this.upperContext.canvas.width, 0);
            this.upperContext.scale(-1, 1);
        };
        Transform.prototype.verticalFlip = function () {
            this.lowerContext.translate(0, this.lowerContext.canvas.height);
            this.lowerContext.scale(1, -1);
            this.upperContext.translate(0, this.upperContext.canvas.height);
            this.upperContext.scale(1, -1);
        };
        Transform.prototype.updateFlipColl = function (direction) {
            if (this.isPreventSelect) {
                return;
            }
            if (this.flipColl.length === 0 || this.flipColl[this.flipColl.length - 1] !== direction) {
                this.flipColl.push(direction);
            }
            else {
                this.flipColl.pop();
            }
            if (this.flipColl.length >= 4) {
                var lastFourItems = this.flipColl.slice(-4);
                Eif ((lastFourItems[0] === 'horizontal' && lastFourItems[1] === 'vertical' &&
                    lastFourItems[2] === 'horizontal' && lastFourItems[3] === 'vertical') ||
                    (lastFourItems[0] === 'vertical' && lastFourItems[1] === 'horizontal' &&
                        lastFourItems[2] === 'vertical' && lastFourItems[3] === 'horizontal')) {
                    this.flipColl.splice(-4);
                }
            }
        };
        Transform.prototype.setDestPointsForFlipState = function () {
            var parent = this.parent;
            var panObj = { panRegion: '' };
            var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
            var _b = parent.lowerCanvas, clientWidth = _b.clientWidth, clientHeight = _b.clientHeight;
            parent.notify('crop', { prop: 'getCurrFlipState', onPropertyChange: false,
                value: { panObj: panObj } });
            if (panObj['panRegion'] !== '') {
                if (panObj['panRegion'] === 'horizontal') {
                    parent.img.destLeft = clientWidth - (destWidth + destLeft);
                }
                else if (panObj['panRegion'] === 'vertical') {
                    parent.img.destTop = clientHeight - (destHeight + destTop);
                }
                else {
                    parent.img.destLeft = clientWidth - (destWidth + destLeft);
                    parent.img.destTop = clientHeight - (destHeight + destTop);
                }
            }
        };
        Transform.prototype.zoomAction = function (zoomFactor, zoomPoint, isResize, isPreventApply) {
            var parent = this.parent;
            if (!parent.disabled && parent.isImageLoaded) {
                if (ej2_base_1.isNullOrUndefined(isResize) && (parent.zoomSettings.zoomFactor >= parent.zoomSettings.maxZoomFactor && zoomFactor > 0 ||
                    (parent.zoomSettings.zoomFactor > parent.zoomSettings.minZoomFactor && zoomFactor < 0 && this.disableZoomOutBtn(true)) ||
                    (parent.zoomSettings.zoomFactor <= parent.zoomSettings.minZoomFactor && zoomFactor < 0))) {
                    parent.notify('toolbar', { prop: 'zoom-up-handler', onPropertyChange: false });
                    return;
                }
                parent.notify('draw', { prop: 'setImageEdited', onPropertyChange: false });
                var tempZoomFactor = zoomFactor;
                zoomFactor = tempZoomFactor > 0 ? 0.1 : -0.1;
                for (var i = 0; i < Math.round(Math.abs(tempZoomFactor / 0.1)); i++) {
                    if (this.prevZoomValue === 1) {
                        this.prevZoomValue += zoomFactor > 0 ? zoomFactor * 10 : (zoomFactor * 10) / 10;
                    }
                    else if (this.prevZoomValue > 1) {
                        this.prevZoomValue += (zoomFactor * 10);
                    }
                    else Eif (this.prevZoomValue < 1) {
                        this.prevZoomValue += (zoomFactor * 10) / 10;
                        var powerOften = Math.pow(10, 1);
                        this.prevZoomValue = (Math.round(this.prevZoomValue * powerOften) / powerOften);
                    }
                }
                zoomFactor = tempZoomFactor;
                parent.setProperties({ zoomSettings: { zoomFactor: this.prevZoomValue } }, true);
                var splitWords = void 0;
                this.tempActiveObj = null;
                this.isShape = false;
                if (parent.activeObj.shape !== undefined) {
                    Iif (parent.activeObj.shape === 'shape') {
                        parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
                    }
                    else {
                        splitWords = parent.activeObj.shape.split('-');
                    }
                }
                if (splitWords !== undefined && splitWords[0] === 'crop') {
                    this.tempActiveObj = ej2_base_1.extend({}, parent.activeObj, {}, true);
                    parent.isCropTab = true;
                }
                else if (parent.activeObj.shape && splitWords[0] !== 'crop' &&
                    (parent.activeObj.activePoint.width !== 0 || parent.activeObj.activePoint.height !== 0) ||
                    (parent.activeObj.shape === 'path' && parent.activeObj.pointColl.length > 0)) {
                    this.isShape = true;
                }
                var obj = { zoomType: null };
                parent.notify('selection', { prop: 'getZoomType', onPropertyChange: false, value: { obj: obj } });
                Eif (ej2_base_1.isNullOrUndefined(zoomPoint)) {
                    if (parent.isCropTab && this.tempActiveObj) {
                        zoomPoint = { x: parent.activeObj.activePoint.startX + (parent.activeObj.activePoint.width / 2),
                            y: parent.activeObj.activePoint.startY + (parent.activeObj.activePoint.height / 2) };
                    }
                    else {
                        zoomPoint = { x: parent.lowerCanvas.clientWidth / 2, y: parent.lowerCanvas.clientHeight / 2 };
                    }
                    Iif (obj['zoomType'] === 'MouseWheel' || obj['zoomType'] === 'Pinch') {
                        zoomPoint = { x: parent.zoomSettings.zoomPoint.x, y: parent.zoomSettings.zoomPoint.y };
                    }
                }
                var previousZoomFactor = parent.zoomSettings.zoomFactor - (zoomFactor * 10);
                var zoomEventArgs = { zoomPoint: zoomPoint, cancel: false, previousZoomFactor: previousZoomFactor,
                    currentZoomFactor: parent.zoomSettings.zoomFactor, zoomTrigger: obj['zoomType'] };
                if (!parent.isCropToolbar && parent.isZoomBtnClick) {
                    parent.trigger('zooming', zoomEventArgs);
                    parent.editCompleteArgs = zoomEventArgs;
                }
                this.zoomEvent(zoomEventArgs, zoomFactor, isPreventApply);
            }
        };
        Transform.prototype.zoomEvent = function (zoomEventArgs, zoomFact, isPreventApply) {
            var parent = this.parent;
            var shapeId;
            var _a = parent.zoomSettings, zoomFactor = _a.zoomFactor, minZoomFactor = _a.minZoomFactor;
            if (zoomEventArgs.cancel) {
                parent.isZoomBtnClick = false;
                return;
            }
            if (this.parent.activeObj.redactType !== 'blur' && this.parent.activeObj.redactType !== 'pixelate') {
                parent.notify('toolbar', { prop: 'close-contextual-toolbar', onPropertyChange: false });
            }
            if (!parent.isCropTab && parent.activeObj.shape) {
                shapeId = parent.activeObj.currIndex;
            }
            parent.notify('shape', { prop: 'redrawActObj', onPropertyChange: false,
                value: { x: null, y: null, isMouseDown: true } });
            parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
            this.upperContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
            var object = { canvasFilter: parent.canvasFilter };
            this.lowerContext.filter = object['canvasFilter'];
            parent.upperCanvas.style.cursor = parent.cursor = 'default';
            var objColl = ej2_base_1.extend([], parent.objColl, [], true);
            if (!parent.isCropTab) {
                if (parent.transform.degree !== 0) {
                    parent.notify('shape', { prop: 'redrawActObj', onPropertyChange: false, value: { x: null, y: null, isMouseDown: null } });
                    parent.panPoint.currentPannedPoint = { x: 0, y: 0 };
                    var temp = parent.allowDownScale;
                    parent.allowDownScale = false;
                    this.rotatePan(true, true);
                    parent.allowDownScale = temp;
                }
                else if (parent.transform.currFlipState !== '') {
                    parent.panPoint.totalPannedPoint = { x: 0, y: 0 };
                }
                if (parent.transform.straighten === 0 && !this.isPreventSelect) {
                    parent.notify('freehand-draw', { prop: 'updateFHDColl', onPropertyChange: false, value: { isPreventApply: isPreventApply } });
                }
            }
            if (parent.transform.degree === 0) {
                this.drawZoomImgToCanvas(zoomFact, this.tempActiveObj);
                var panObj_1 = { panRegion: '' };
                parent.notify('crop', { prop: 'getCurrFlipState', onPropertyChange: false, value: { panObj: panObj_1 } });
                if (panObj_1['panRegion'] !== '') {
                    parent.notify('crop', { prop: 'setTempFlipPanPoint', onPropertyChange: false, value: { point: parent.panPoint.totalPannedPoint, isAdd: true } });
                    objColl = ej2_base_1.extend([], parent.objColl, [], true);
                    parent.objColl = [];
                    var destLeft = parent.img.destLeft;
                    var destTop = parent.img.destTop;
                    this.setDestPointsForFlipState();
                    this.rotatedFlip();
                    parent.img.destLeft = destLeft;
                    parent.img.destTop = destTop;
                    parent.objColl = objColl;
                    parent.notify('shape', { prop: 'drawAnnotations', onPropertyChange: false,
                        value: { ctx: this.lowerContext, shape: 'zoom', pen: 'zoom', isPreventApply: isPreventApply } });
                    Eif (parent.transform.straighten === 0 && !this.isPreventSelect) {
                        parent.notify('freehand-draw', { prop: 'updateFHDColl', onPropertyChange: false, value: { isPreventApply: isPreventApply } });
                    }
                }
                if (zoomFactor <= minZoomFactor && !parent.isCropTab) {
                    parent.panPoint.totalPannedPoint = { x: 0, y: 0 };
                }
            }
            else {
                if (parent.transform.straighten === 0 && !this.isPreventSelect) {
                    parent.notify('freehand-draw', { prop: 'updateFHDColl', onPropertyChange: false, value: { isPreventApply: isPreventApply } });
                }
                parent.panPoint.totalPannedClientPoint = { x: 0, y: 0 };
                parent.panPoint.totalPannedInternalPoint = { x: 0, y: 0 };
                this.rotateZoom(zoomFact);
                var panObj_2 = { panRegion: '' };
                parent.notify('crop', { prop: 'getCurrFlipState', onPropertyChange: false, value: { panObj: panObj_2 } });
                if (panObj_2['panRegion'] !== '') {
                    var temp = this.lowerContext.filter;
                    this.lowerContext.filter = 'none';
                    parent.notify('shape', { prop: 'drawAnnotations', onPropertyChange: false,
                        value: { ctx: this.lowerContext, shape: 'zoom', pen: 'zoom', isPreventApply: isPreventApply } });
                    this.lowerContext.filter = temp;
                }
            }
            var powerOften = Math.pow(10, 1);
            if (zoomFactor <= minZoomFactor ||
                (Math.round(parent.transform.zoomFactor * powerOften) / powerOften) === 2) {
                clearInterval(this.zoomBtnHold);
                this.zoomBtnHold = 0;
            }
            var panObj = { panRegion: '' };
            parent.notify('crop', { prop: 'getCurrFlipState', onPropertyChange: false, value: { panObj: panObj } });
            if (panObj['panRegion'] === '') {
                var temp = this.lowerContext.filter;
                this.lowerContext.filter = 'none';
                parent.notify('shape', { prop: 'drawAnnotations', onPropertyChange: false,
                    value: { ctx: this.lowerContext, shape: 'zoom', pen: 'zoom', isPreventApply: isPreventApply } });
                this.lowerContext.filter = temp;
            }
            if ((parent.currSelectionPoint && parent.currSelectionPoint.shape === 'crop-circle') || parent.isCircleCrop) {
                parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
                    value: { context: this.lowerContext, isSave: null, isFlip: null } });
            }
            parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.lowerContext } });
            parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
            if (this.tempActiveObj) {
                parent.activeObj = ej2_base_1.extend({}, this.tempActiveObj, {}, true);
                parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: parent.activeObj } });
                if (zoomFactor <= minZoomFactor) {
                    parent.currSelectionPoint = null;
                }
            }
            parent.isUndoRedo = false;
            var zoomOut;
            zoomOut = document.querySelector('#' + parent.element.id + '_zoomOut');
            if (zoomOut && zoomFactor <= minZoomFactor) {
                zoomOut.classList.add('e-disabled');
                zoomOut.parentElement.classList.add('e-overlay');
            }
            else if (zoomOut) {
                zoomOut.classList.remove('e-disabled');
                zoomOut.parentElement.classList.remove('e-overlay');
            }
            var drawingShape = parent.drawingShape;
            this.autoEnablePan();
            parent.drawingShape = drawingShape;
            if (this.tempActiveObj) {
                parent.activeObj = ej2_base_1.extend({}, this.tempActiveObj, {}, true);
            }
            if (parent.activeObj.shape === 'crop-custom') {
                parent.currObjType.isCustomCrop = true;
            }
            if (this.isShape) {
                Eif (shapeId) {
                    for (var i = 0, len = parent.objColl.length; i < len; i++) {
                        Eif (parent.objColl[i].currIndex === shapeId) {
                            parent.activeObj = ej2_base_1.extend({}, parent.objColl[i], {}, true);
                            parent.objColl.splice(i, 1);
                            break;
                        }
                    }
                }
                else {
                    parent.activeObj = ej2_base_1.extend({}, parent.objColl[parent.objColl.length - 1], {}, true);
                    parent.objColl.pop();
                }
                parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: parent.activeObj, isCropRatio: null,
                        points: null, isPreventDrag: true, saveContext: null, isPreventSelection: null } });
                parent.notify('toolbar', { prop: 'update-toolbar-items', onPropertyChange: false });
                parent.notify('toolbar', { prop: 'renderQAT', onPropertyChange: false, value: { isPenEdit: null } });
            }
            parent.notify('toolbar', { prop: 'enable-disable-btns', onPropertyChange: false });
            parent.notify('selection', { prop: 'setZoomType', onPropertyChange: false, value: { zoomType: 'Toolbar' } });
            zoomEventArgs = { zoomPoint: zoomEventArgs.zoomPoint, previousZoomFactor: zoomEventArgs.previousZoomFactor, currentZoomFactor: zoomEventArgs.currentZoomFactor, zoomTrigger: zoomEventArgs.zoomTrigger };
            if (!parent.isCropToolbar && parent.isZoomBtnClick) {
                parent.isZoomBtnClick = false;
            }
            if (parent.drawingShape) {
                var activeObj = ej2_base_1.extend({}, parent.activeObj, {}, true);
                parent.enableShapeDrawing(parent.toPascalCase(parent.drawingShape), true);
                parent.activeObj = activeObj;
                Iif (activeObj.activePoint.width > 0 || activeObj.activePoint.height > 0 ||
                    (activeObj.pointColl && activeObj.pointColl.length > 0)) {
                    if (activeObj.shape === 'redact') {
                        parent.notify('toolbar', { prop: 'renderQAT', onPropertyChange: false, value: { isPenEdit: null } });
                    }
                    var zOrderElem = parent.element.querySelector('#' + parent.element.id + '_zOrderBtn');
                    var dupElem = parent.element.querySelector('#' + parent.element.id + '_duplicate');
                    var removeElem = parent.element.querySelector('#' + parent.element.id + '_remove');
                    var editTextElem = parent.element.querySelector('#' + parent.element.id + '_editText');
                    if (zOrderElem) {
                        zOrderElem.classList.remove('e-overlay');
                    }
                    if (dupElem) {
                        dupElem.classList.remove('e-overlay');
                    }
                    if (removeElem) {
                        removeElem.classList.remove('e-overlay');
                    }
                    if (editTextElem) {
                        editTextElem.classList.remove('e-overlay');
                    }
                }
            }
            else Iif (parent.activeObj.shape && parent.activeObj.shape === 'redact') {
                parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'redact',
                        isApplyBtn: false, isCropping: false } });
                parent.notify('toolbar', { prop: 'renderQAT', onPropertyChange: false, value: { isPenEdit: null } });
            }
        };
        Transform.prototype.disableZoomOutBtn = function (isZoomOut) {
            var parent = this.parent;
            var _a = parent.zoomSettings, zoomFactor = _a.zoomFactor, minZoomFactor = _a.minZoomFactor;
            var isDisabled = false;
            var zoomOut;
            Eif (!ej2_base_1.isNullOrUndefined(isZoomOut)) {
                parent.transform.zoomFactor -= 0.1;
            }
            zoomOut = parent.element.querySelector('#' + parent.element.id + '_zoomOut');
            var destPoints = { destLeft: parent.img.destLeft, destTop: parent.img.destTop,
                destWidth: parent.img.destWidth, destHeight: parent.img.destHeight };
            if (parent.activeObj.shape) {
                var maxDimension = this.setZoomDimension(-0.1, parent.activeObj);
                var actPoint = parent.activeObj.activePoint;
                if (parent.transform.straighten === 0) {
                    if (parent.img.destLeft > actPoint.startX || parent.img.destTop >
                        actPoint.startY || parent.img.destLeft + parent.img.destWidth <
                        actPoint.endX || parent.img.destTop + parent.img.destHeight < actPoint.endY
                        || zoomFactor === minZoomFactor) {
                        isDisabled = true;
                    }
                    else {
                        isDisabled = false;
                    }
                }
                else {
                    parent.img.destWidth = maxDimension.width;
                    parent.img.destHeight = maxDimension.height;
                    var obj = { isIntersect: null };
                    parent.notify('draw', { prop: 'updateImgCanvasPoints', onPropertyChange: false });
                    parent.notify('draw', { prop: 'isLinesIntersect', onPropertyChange: false, value: { obj: obj } });
                    if (obj['isIntersect'] ||
                        zoomFactor === minZoomFactor) {
                        isDisabled = true;
                    }
                    else {
                        isDisabled = false;
                    }
                }
                Eif (zoomOut) {
                    if (isDisabled) {
                        zoomOut.classList.add('e-disabled');
                        zoomOut.parentElement.classList.add('e-overlay');
                    }
                    else {
                        zoomOut.classList.remove('e-disabled');
                        zoomOut.parentElement.classList.remove('e-overlay');
                    }
                }
            }
            else {
                this.setZoomDimension(-0.1, null);
            }
            Eif (!ej2_base_1.isNullOrUndefined(isZoomOut)) {
                parent.transform.zoomFactor += 0.1;
            }
            parent.img.destLeft = destPoints['destLeft'];
            parent.img.destTop = destPoints['destTop'];
            parent.img.destWidth = destPoints['destWidth'];
            parent.img.destHeight = destPoints['destHeight'];
            return isDisabled;
        };
        Transform.prototype.drawZoomImgToCanvas = function (value, selectionObj) {
            var parent = this.parent;
            var powerOften = Math.pow(10, 1);
            var zmFactor = Math.round(parent.transform.zoomFactor * powerOften) / powerOften;
            if ((zmFactor === 0.1 && value === -0.1) || zmFactor === 0 && value === -0.025) {
                parent.transform.zoomFactor = 0;
            }
            else {
                parent.transform.zoomFactor += value;
            }
            parent.transform[parent.isCropTab ? 'cropZoomFactor' : 'defaultZoomFactor'] = parent.transform.zoomFactor;
            var maxDimension = { width: 0, height: 0 };
            if (parent.isCropTab) {
                maxDimension = this.cropZoom(value, selectionObj);
            }
            else {
                maxDimension = this.calcMaxDimension(parent.img.srcWidth, parent.img.srcHeight);
                maxDimension.width += (maxDimension.width * parent.transform.zoomFactor);
                maxDimension.height += (maxDimension.height * parent.transform.zoomFactor);
                parent.img.destLeft = (parent.lowerCanvas.clientWidth - maxDimension.width) / 2;
                parent.img.destTop = (parent.lowerCanvas.clientHeight - maxDimension.height) / 2;
            }
            parent.notify('draw', { prop: 'draw-image-to-canvas', value: { dimension: maxDimension } });
            maxDimension.width = this.cropDimension.width;
            maxDimension.height = this.cropDimension.height;
            maxDimension.width += (maxDimension.width * parent.transform.zoomFactor);
            maxDimension.height += (maxDimension.height * parent.transform.zoomFactor);
            parent.notify('draw', { prop: 'setZoomCropWidth', value: { width: maxDimension.width, height: maxDimension.height } });
        };
        Transform.prototype.rotatedFlip = function () {
            var parent = this.parent;
            this.isReverseFlip = true;
            var tempCurrFlipState = parent.transform.currFlipState;
            var tempFlipColl = this.flipColl;
            var tempObjColl = ej2_base_1.extend([], parent.objColl, [], true);
            var tempActiveObj = ej2_base_1.extend({}, parent.activeObj, {}, true);
            this.flipColl = [];
            parent.objColl = [];
            parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
            parent.notify('draw', { prop: 'currTransState', onPropertyChange: false,
                value: { type: 'initial', isPreventDestination: null, context: null, isPreventCircleCrop: null } });
            var temp = this.lowerContext.filter;
            parent.notify('draw', { prop: 'drawImage', onPropertyChange: false });
            this.lowerContext.filter = temp;
            parent.notify('draw', { prop: 'currTransState', onPropertyChange: false,
                value: { type: 'reverse', isPreventDestination: true, context: null, isPreventCircleCrop: null } });
            Iif (tempCurrFlipState === '' && parent.transform.currFlipState !== '') {
                tempCurrFlipState = parent.transform.currFlipState;
            }
            parent.transform.currFlipState = tempCurrFlipState;
            this.flipColl = tempFlipColl;
            parent.objColl = ej2_base_1.extend([], tempObjColl, [], true);
            this.lowerContext.filter = 'none';
            parent.notify('shape', { prop: 'iterateObjColl', onPropertyChange: false });
            this.lowerContext.filter = temp;
            Iif (tempActiveObj.activePoint.width !== 0) {
                parent.activeObj = ej2_base_1.extend({}, tempActiveObj, {}, true);
            }
            this.isReverseFlip = false;
        };
        Transform.prototype.rotateZoom = function (value) {
            var parent = this.parent;
            var powerOften = Math.pow(10, 1);
            var zmFactor = Math.round(parent.transform.zoomFactor * powerOften) / powerOften;
            if ((zmFactor === 0.1 && value === -0.1) || zmFactor === 0 && value === -0.025) {
                parent.transform.zoomFactor = 0;
            }
            else {
                parent.transform.zoomFactor += value;
            }
            if (parent.isCropTab) {
                parent.transform.cropZoomFactor = parent.transform.zoomFactor;
            }
            else {
                parent.transform.defaultZoomFactor = parent.transform.zoomFactor;
            }
            var tempObjColl = ej2_base_1.extend([], parent.objColl, [], true);
            var tempActiveObj = ej2_base_1.extend({}, parent.activeObj, {}, true);
            parent.objColl = [];
            parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
            parent.notify('draw', { prop: 'updateCurrTransState', onPropertyChange: false,
                value: { type: 'initial', isPreventDestination: null, isRotatePan: null } });
            parent.notify('draw', { prop: 'setRotateZoom', onPropertyChange: false, value: { isRotateZoom: true } });
            parent.notify('draw', { prop: 'setDestPoints', onPropertyChange: false });
            var temp = this.lowerContext.filter;
            parent.notify('draw', { prop: 'drawImage', onPropertyChange: false });
            this.lowerContext.filter = temp;
            parent.notify('draw', { prop: 'setRotateZoom', onPropertyChange: false, value: { isRotateZoom: false } });
            parent.notify('draw', { prop: 'updateCurrTransState', onPropertyChange: false,
                value: { type: 'reverse', isPreventDestination: null, isRotatePan: null } });
            parent.objColl = tempObjColl;
            parent.activeObj = tempActiveObj;
            var maxDimension = { width: this.cropDimension.width, height: this.cropDimension.height };
            maxDimension.width += (maxDimension.width * parent.transform.zoomFactor);
            maxDimension.height += (maxDimension.height * parent.transform.zoomFactor);
            parent.notify('draw', { prop: 'setZoomCropWidth', value: { width: maxDimension.width, height: maxDimension.height } });
        };
        Transform.prototype.autoEnablePan = function () {
            var parent = this.parent;
            if (parent.transform.zoomFactor <= 0) {
                parent.togglePan = false;
                parent.notify('selection', { prop: 'setDragCanvas', value: { bool: false } });
                parent.pan(false);
                this.disablePan = false;
            }
            else {
                parent.pan(!this.disablePan);
            }
        };
        Transform.prototype.cropZoom = function (value, selectionObj) {
            var parent = this.parent;
            var destLeft = parent.img.destLeft;
            var destTop = parent.img.destTop;
            var maxDimension = { width: 0, height: 0 };
            Iif (parent.transform.degree % 90 === 0 && parent.transform.degree % 180 !== 0) {
                maxDimension = this.calcMaxDimension(parent.img.srcHeight, parent.img.srcWidth);
            }
            else {
                maxDimension = this.calcMaxDimension(parent.img.srcWidth, parent.img.srcHeight);
            }
            maxDimension.width += (maxDimension.width * parent.transform.zoomFactor);
            maxDimension.height += (maxDimension.height * parent.transform.zoomFactor);
            parent.img.destLeft = destLeft - ((maxDimension.width - parent.img.destWidth) / 2);
            parent.img.destTop = destTop - ((maxDimension.height - parent.img.destHeight) / 2);
            destLeft = parent.img.destLeft;
            destTop = parent.img.destTop;
            if (selectionObj && parent.transform.straighten === 0) {
                Iif (parent.img.destLeft > selectionObj.activePoint.startX) {
                    parent.img.destLeft = selectionObj.activePoint.startX;
                    if (parent.transform.degree === 0) {
                        parent.panPoint.totalPannedPoint.x -= (destLeft - parent.img.destLeft);
                    }
                }
                Iif (parent.img.destTop > selectionObj.activePoint.startY) {
                    parent.img.destTop = selectionObj.activePoint.startY;
                    if (parent.transform.degree === 0) {
                        parent.panPoint.totalPannedPoint.y -= (destTop - parent.img.destTop);
                    }
                }
                Iif (parent.img.destLeft + maxDimension.width < selectionObj.activePoint.endX) {
                    parent.img.destLeft = selectionObj.activePoint.endX - maxDimension.width;
                    if (parent.transform.degree === 0) {
                        parent.panPoint.totalPannedPoint.x -= (destLeft - parent.img.destLeft);
                    }
                }
                Iif (parent.img.destTop + maxDimension.height < selectionObj.activePoint.endY) {
                    parent.img.destTop = selectionObj.activePoint.endY - maxDimension.height;
                    if (parent.transform.degree === 0) {
                        parent.panPoint.totalPannedPoint.y -= (destTop - parent.img.destTop);
                    }
                }
            }
            return maxDimension;
        };
        Transform.prototype.setZoomDimension = function (value, selectionObj) {
            var parent = this.parent;
            var degree = parent.transform.degree;
            var maxDimension = { width: 0, height: 0 };
            if (degree % 90 === 0 && degree % 180 !== 0) {
                maxDimension = this.calcMaxDimension(parent.img.srcHeight, parent.img.srcWidth);
            }
            else {
                maxDimension = this.calcMaxDimension(parent.img.srcWidth, parent.img.srcHeight);
            }
            maxDimension.width += (maxDimension.width * parent.transform.zoomFactor);
            maxDimension.height += (maxDimension.height * parent.transform.zoomFactor);
            parent.img.destLeft += ((parent.img.destWidth - maxDimension.width) / 2);
            parent.img.destTop += ((parent.img.destHeight - maxDimension.height) / 2);
            if (value < 0 && selectionObj) {
                var startX = selectionObj.activePoint.startX;
                var startY = selectionObj.activePoint.startY;
                var width = selectionObj.activePoint.width;
                var height = selectionObj.activePoint.height;
                var maxDestLeft = parent.img.destLeft + maxDimension.width;
                var maxDestTop = parent.img.destTop + maxDimension.height;
                if (parent.img.destLeft > startX) {
                    parent.img.destLeft = startX;
                }
                if (parent.img.destTop > startY) {
                    parent.img.destTop = startY;
                }
                if (maxDestLeft < startX + width) {
                    parent.img.destLeft = startX + width - maxDimension.width;
                }
                if (maxDestTop < startY + height) {
                    parent.img.destTop = startY + height - maxDimension.height;
                }
            }
            else Eif (value < 0 && ej2_base_1.isNullOrUndefined(selectionObj)) {
                if (parent.img.destLeft > 0) {
                    parent.img.destLeft = 0;
                }
                if (parent.img.destTop > 0) {
                    parent.img.destTop = 0;
                }
                if (parent.img.destLeft + maxDimension.width < parent.lowerCanvas.clientWidth) {
                    parent.img.destLeft = parent.lowerCanvas.clientWidth - parent.img.destWidth;
                }
                if (parent.img.destTop + maxDimension.height < parent.lowerCanvas.clientHeight) {
                    parent.img.destTop = parent.lowerCanvas.clientHeight - parent.img.destHeight;
                }
            }
            return maxDimension;
        };
        Transform.prototype.drawPannedImage = function (xDiff, yDiff) {
            var parent = this.parent;
            var obj = { panDown: null };
            parent.notify('selection', { prop: 'getPanDown', onPropertyChange: false, value: { obj: obj } });
            var panEventArgs = { startPoint: obj['panDown'], endPoint: this.panMove, cancel: false };
            parent.trigger('panning', panEventArgs);
            Iif (panEventArgs.cancel) {
                return;
            }
            this.panEvent(xDiff, yDiff);
        };
        Transform.prototype.panEvent = function (xDiff, yDiff, isPanMethod) {
            var parent = this.parent;
            var isObjCreated = false;
            Iif (parent.activeObj.shape && parent.activeObj.shape === 'shape') {
                parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
            }
            if (ej2_base_1.isNullOrUndefined(parent.activeObj.shape)) {
                isObjCreated = true;
                var actPoint = parent.activeObj.activePoint = { startX: parent.img.destLeft, startY: parent.img.destTop,
                    endX: parent.img.destLeft + parent.img.destWidth, endY: parent.img.destTop + parent.img.destHeight };
                var startX = actPoint.startX;
                var startY = actPoint.startY;
                var endX = actPoint.endX;
                var endY = actPoint.endY;
                Iif (startX < 0) {
                    actPoint.startX = 0;
                }
                if (startY < 0) {
                    actPoint.startY = 0;
                }
                Iif (endX > parent.lowerCanvas.width) {
                    actPoint.endX = parent.lowerCanvas.width;
                }
                if (endY > parent.lowerCanvas.height) {
                    actPoint.endY = parent.lowerCanvas.height;
                }
                actPoint.width = actPoint.endX - actPoint.startX;
                actPoint.height = actPoint.endY - actPoint.startY;
                parent.activeObj.shape = 'crop-custom';
                var obj = { strokeSettings: {} };
                parent.notify('shape', { prop: 'getStrokeSettings', onPropertyChange: false, value: { obj: obj } });
                parent.activeObj.strokeSettings = obj['strokeSettings'];
                parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: actPoint, obj: parent.activeObj,
                        isMouseMove: null, x: null, y: null } });
                parent.isCropTab = true;
            }
            if (parent.transform.degree === 0) {
                var point = void 0;
                if ((ej2_base_1.isNullOrUndefined(xDiff) && ej2_base_1.isNullOrUndefined(yDiff)) || isPanMethod) {
                    if (isPanMethod) {
                        point = this.updatePanPoints(xDiff, yDiff);
                    }
                    else {
                        point = this.updatePanPoints();
                    }
                }
                else {
                    point = { x: xDiff, y: yDiff };
                }
                parent.panPoint.totalPannedPoint.x += point.x;
                parent.panPoint.totalPannedPoint.y += point.y;
                var tempSelectionObj = ej2_base_1.extend({}, parent.activeObj, {}, true);
                var temp = this.lowerContext.filter;
                this.drawPannImage(point, isObjCreated);
                this.lowerContext.filter = temp;
                this.tempPanMove = ej2_base_1.extend({}, this.panMove, {}, true);
                parent.activeObj = ej2_base_1.extend({}, tempSelectionObj, {}, true);
                this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
                Eif (parent.activeObj.shape) {
                    parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: parent.activeObj } });
                }
            }
            else {
                var tempFlipState = parent.transform.currFlipState;
                parent.isCropTab = true;
                Iif ((ej2_base_1.isNullOrUndefined(xDiff) && ej2_base_1.isNullOrUndefined(yDiff)) || isPanMethod) {
                    if (isPanMethod) {
                        parent.panPoint.currentPannedPoint = this.updatePanPoints(xDiff, yDiff);
                    }
                    else {
                        parent.panPoint.currentPannedPoint = this.updatePanPoints();
                    }
                }
                else {
                    parent.panPoint.currentPannedPoint = { x: xDiff, y: yDiff };
                }
                parent.transform.currFlipState = tempFlipState;
                this.rotatePan(null, null, isObjCreated);
                parent.isCropTab = false;
                this.tempPanMove = ej2_base_1.extend({}, this.panMove, {}, true);
            }
            if (isObjCreated) {
                parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
                parent.isCropTab = false;
                this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
            }
        };
        Transform.prototype.drawPannImage = function (point, isObjCreated) {
            var parent = this.parent;
            var filter = this.lowerContext.filter;
            var destPoints = { startX: parent.img.destLeft, startY: parent.img.destTop, width: parent.img.destWidth,
                height: parent.img.destHeight };
            this.lowerContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
            parent.notify('draw', { prop: 'updateCurrTransState', onPropertyChange: false,
                value: { type: 'initial', isPreventDestination: null, isRotatePan: null } });
            parent.img.destLeft = destPoints.startX;
            parent.img.destTop = destPoints.startY;
            parent.img.destWidth = destPoints.width;
            parent.img.destHeight = destPoints.height;
            this.setDestPointsForFlipState();
            if (isObjCreated) {
                parent.isCropTab = false;
            }
            parent.notify('draw', { prop: 'drawImage', onPropertyChange: false });
            if (isObjCreated) {
                parent.isCropTab = true;
            }
            Iif ((parent.currSelectionPoint && parent.currSelectionPoint.shape === 'crop-circle') || parent.isCircleCrop) {
                parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
                    value: { context: this.lowerContext, isSave: null, isFlip: true } });
            }
            this.lowerContext.filter = filter;
            parent.notify('draw', { prop: 'updateCurrTransState', onPropertyChange: false,
                value: { type: 'reverse', isPreventDestination: null, isRotatePan: null } });
            parent.img.destLeft = destPoints.startX;
            parent.img.destTop = destPoints.startY;
            parent.img.destWidth = destPoints.width;
            parent.img.destHeight = destPoints.height;
            var temp = this.lowerContext.filter;
            this.lowerContext.filter = 'none';
            if (isObjCreated) {
                parent.isCropTab = false;
            }
            parent.notify('shape', { prop: 'drawAnnotations', onPropertyChange: false,
                value: { ctx: this.lowerContext, shape: 'pan', pen: 'pan', x: point.x,
                    y: point.y, panRegion: '' } });
            if (isObjCreated) {
                parent.isCropTab = true;
            }
            this.lowerContext.filter = temp;
            parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.lowerContext } });
            Iif (parent.isCircleCrop) {
                parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
                    value: { context: this.lowerContext, isSave: null, isFlip: true } });
            }
        };
        Transform.prototype.resetZoom = function () {
            var parent = this.parent;
            if (parent.transform.defaultZoomFactor !== 0) {
                var isUndoRedo = parent.isUndoRedo;
                var object = { currObj: {} };
                parent.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
                this.transCurrObj = object['currObj'];
                this.transCurrObj.objColl = ej2_base_1.extend([], parent.objColl, null, true);
                this.transCurrObj.pointColl = ej2_base_1.extend({}, parent.pointColl, null, true);
                this.transCurrObj.afterCropActions = ej2_base_1.extend([], parent.afterCropActions, [], true);
                var selPointCollObj = { selPointColl: null };
                parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
                    value: { obj: selPointCollObj } });
                this.transCurrObj.selPointColl = ej2_base_1.extend([], selPointCollObj['selPointColl'], [], true);
                parent.isUndoRedo = parent.isCropToolbar = true;
                var zmFactor = parent.transform.defaultZoomFactor;
                if (zmFactor > 0) {
                    this.zoomAction(-zmFactor);
                }
                else {
                    this.zoomAction(Math.abs(zmFactor));
                }
                parent.isCropToolbar = false;
                parent.isUndoRedo = isUndoRedo;
            }
        };
        Transform.prototype.performTransformation = function (text) {
            var parent = this.parent;
            this.resetZoom();
            this.updateTransform(text);
            for (var i = 0, len = parent.objColl.length; i < len; i++) {
                if (parent.objColl[i].flipObjColl.length > 0) {
                    var flipObjColl = { collection: parent.objColl[i].flipObjColl };
                    parent.notify('shape', { prop: 'alignRotateFlipColl', onPropertyChange: false,
                        value: { collection: flipObjColl['collection'], isRotateFlipCollection: null, obj: flipObjColl } });
                    parent.objColl[i].flipObjColl = flipObjColl['collection'];
                    Iif (parent.objColl[i].flipObjColl.length === 0) {
                        parent.objColl[i].shapeFlip = '';
                    }
                }
            }
        };
        Transform.prototype.updateTransform = function (text) {
            switch (text.toLowerCase()) {
                case 'rotateleft':
                    this.rotateImage(-90);
                    break;
                case 'rotateright':
                    this.rotateImage(90);
                    break;
                case 'horizontalflip':
                    this.flipImage(index_1.Direction.Horizontal);
                    break;
                case 'verticalflip':
                    this.flipImage(index_1.Direction.Vertical);
                    break;
            }
        };
        Transform.prototype.rotatePan = function (isCropSelection, isDefaultZoom, isObjCreated) {
            var parent = this.parent;
            this.isReverseRotate = true;
            var tempDegree = parent.transform.degree;
            var rotatePanActiveObj;
            var object = { selPointColl: null };
            if (parent.activeObj.activePoint && parent.activeObj.shape) {
                rotatePanActiveObj = ej2_base_1.extend({}, parent.activeObj, {}, true);
            }
            var tempObjColl = ej2_base_1.extend([], parent.objColl, [], true);
            var tempPointColl = ej2_base_1.extend([], parent.pointColl, [], true);
            parent.objColl = [];
            parent.pointColl = [];
            parent.freehandCounter = 0;
            parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false, value: { obj: object } });
            var cropSelPointColl = object['selPointColl'];
            parent.notify('freehand-draw', { prop: 'setSelPointColl', onPropertyChange: false, value: { obj: { selPointColl: [] } } });
            parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
            parent.notify('draw', { prop: 'setRotateZoom', onPropertyChange: false, value: { isRotateZoom: true } });
            parent.notify('draw', { prop: 'updateCurrTransState', onPropertyChange: false,
                value: { type: 'initial', isPreventDestination: null, isRotatePan: null } });
            var initialDestLeft = parent.img.destLeft;
            var initialDestTop = parent.img.destTop;
            var intPan = parent.panPoint.totalPannedInternalPoint;
            if (parent.isCropTab) {
                parent.img.destLeft += intPan.x;
                parent.img.destTop += intPan.y;
            }
            parent.notify('crop', { prop: 'updateRotatePan', onPropertyChange: false });
            if (parent.isCropTab) {
                parent.panPoint.totalPannedInternalPoint.x = parent.img.destLeft - initialDestLeft;
                parent.panPoint.totalPannedInternalPoint.y = parent.img.destTop - initialDestTop;
            }
            var temp = this.lowerContext.filter;
            if (isObjCreated) {
                parent.isCropTab = false;
            }
            parent.notify('draw', { prop: 'drawImage', onPropertyChange: false });
            if (isObjCreated) {
                parent.isCropTab = true;
            }
            parent.notify('draw', { prop: 'setRotateZoom', onPropertyChange: false, value: { isRotateZoom: false } });
            parent.notify('draw', { prop: 'updateCurrTransState', onPropertyChange: false,
                value: { type: 'reverse', isPreventDestination: true, isRotatePan: true } });
            var destLeft = parent.img.destLeft;
            var destTop = parent.img.destTop;
            parent.img.destLeft += parent.panPoint.totalPannedClientPoint.x;
            parent.img.destTop += parent.panPoint.totalPannedClientPoint.y;
            parent.img.destLeft += parent.panPoint.currentPannedPoint.x;
            parent.img.destTop += parent.panPoint.currentPannedPoint.y;
            parent.panPoint.totalPannedClientPoint.x = parent.img.destLeft - destLeft;
            parent.panPoint.totalPannedClientPoint.y = parent.img.destTop - destTop;
            parent.objColl = tempObjColl;
            parent.pointColl = tempPointColl;
            parent.freehandCounter = parent.pointColl.length;
            parent.notify('freehand-draw', { prop: 'setSelPointColl', onPropertyChange: false,
                value: { obj: { selPointColl: cropSelPointColl } } });
            parent.transform.degree = tempDegree;
            this.lowerContext.filter = 'none';
            if (isCropSelection) {
                Eif (isDefaultZoom) {
                    parent.panPoint.totalPannedClientPoint.x = -parent.panPoint.totalPannedClientPoint.x;
                    parent.panPoint.totalPannedClientPoint.y = -parent.panPoint.totalPannedClientPoint.y;
                    parent.panPoint.currentPannedPoint = ej2_base_1.extend({}, parent.panPoint.totalPannedClientPoint, {}, true);
                    parent.panPoint.totalPannedClientPoint = { x: 0, y: 0 };
                    parent.img.destLeft += parent.panPoint.currentPannedPoint.x;
                    parent.img.destTop += parent.panPoint.currentPannedPoint.y;
                }
                else {
                    parent.panPoint.currentPannedPoint = ej2_base_1.extend({}, parent.panPoint.totalPannedClientPoint, {}, true);
                }
            }
            if (isObjCreated) {
                parent.isCropTab = false;
            }
            parent.notify('shape', { prop: 'drawAnnotations', onPropertyChange: false,
                value: { ctx: this.lowerContext, shape: 'pan', pen: 'pan', x: parent.panPoint.currentPannedPoint.x,
                    y: parent.panPoint.currentPannedPoint.y, panRegion: '' } });
            if (isObjCreated) {
                parent.isCropTab = true;
            }
            this.lowerContext.filter = temp;
            parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.lowerContext } });
            this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
            parent.activeObj = ej2_base_1.extend({}, rotatePanActiveObj, {}, true);
            if (parent.activeObj.activePoint) {
                parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: parent.activeObj, isCropRatio: null,
                        points: null, isPreventDrag: true, saveContext: null, isPreventSelection: null } });
            }
            this.isReverseRotate = false;
        };
        Transform.prototype.limitPan = function () {
            var parent = this.parent;
            var _a = parent.activeObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
            var img = parent.img;
            Eif (parent.activeObj.activePoint) {
                Iif (img.destLeft > startX) {
                    parent.img.destLeft = startX;
                }
                Iif (img.destTop > startY) {
                    parent.img.destTop = startY;
                }
                if (img.destLeft + img.destWidth < endX) {
                    parent.img.destLeft = endX - img.destWidth;
                }
                if (img.destTop + img.destHeight < endY) {
                    parent.img.destTop = endY - img.destHeight;
                }
            }
        };
        Transform.prototype.pan = function (value, x, y) {
            var parent = this.parent;
            Eif (!parent.disabled && parent.isImageLoaded) {
                if (value) {
                    parent.togglePan = true;
                    parent.notify('shape', { prop: 'redrawActObj', onPropertyChange: false,
                        value: { x: null, y: null, isMouseDown: null } });
                    parent.notify('selection', { prop: 'setDragCanvas', value: { bool: true } });
                    parent.lowerCanvas.style.cursor = parent.upperCanvas.style.cursor = parent.cursor = 'grab';
                    parent.notify('selection', { prop: 'setPanDown', onPropertyChange: false, value: { panDown: null } });
                    if (x || y) {
                        x = x ? x : 0;
                        y = y ? y : 0;
                        Eif (ej2_base_1.isNullOrUndefined(this.panMove)) {
                            this.panMove = { x: x, y: y };
                        }
                        Eif (ej2_base_1.isNullOrUndefined(this.tempPanMove)) {
                            this.tempPanMove = { x: this.panMove.x, y: this.panMove.y };
                        }
                        this.panEvent(x, y, true);
                        this.tempPanMove = null;
                    }
                }
                else {
                    parent.togglePan = parent.currObjType.isCustomCrop = false;
                    parent.notify('selection', { prop: 'setDragCanvas', value: { bool: false } });
                    parent.lowerCanvas.style.cursor = parent.upperCanvas.style.cursor = parent.cursor = 'default';
                }
            }
        };
        Transform.prototype.zoom = function (zoomFactor, zoomPoint) {
            var parent = this.parent;
            if (!parent.disabled && parent.isImageLoaded) {
                var value = this.getCurrentZoomFactor(zoomFactor);
                if (ej2_base_1.isNullOrUndefined(zoomPoint)) {
                    this.zoomAction(value, zoomPoint);
                }
                else {
                    var type = value > 0 ? 'zoomIn' : 'zoomOut';
                    var absValue = Math.abs(value) * 10;
                    for (var i = 0; i < absValue; i++) {
                        parent.notify('draw', { prop: 'performPointZoom', onPropertyChange: false,
                            value: { x: zoomPoint.x, y: zoomPoint.y, type: type, isResize: null } });
                    }
                }
                var actionArgs = { action: value > 0 ? 'zoom-in' : 'zoom-out',
                    actionEventArgs: parent.editCompleteArgs };
                parent.triggerEditCompleteEvent(actionArgs);
            }
        };
        Transform.prototype.getCurrentZoomFactor = function (zoomFactor) {
            return zoomFactor >= 1 ? (this.prevZoomValue < 1 ? (zoomFactor - this.prevZoomValue) : (zoomFactor - this.prevZoomValue) * 0.1) :
                (zoomFactor - this.prevZoomValue);
        };
        Transform.prototype.setCurrPanRegion = function (region, type, obj) {
            var panRegion = region;
            if (region === '') {
                panRegion = type === 'horizontal' ? 'horizontal' : type === 'vertical' ? 'vertical' : region;
            }
            else if (region === 'horizontal') {
                panRegion = type === 'horizontal' ? 'horizontalVertical' : type === 'vertical' ? 'verticalHorizontal' : type === 90 ?
                    'vertical' : type === -90 ? 'horizontal' : region;
            }
            else if (region === 'vertical') {
                panRegion = type === 'horizontal' ? 'horizontalVertical' : type === 'vertical' ? 'verticalHorizontal' : type === 90 ?
                    'horizontal' : type === -90 ? 'vertical' : region;
            }
            else {
                panRegion = type === 'horizontal' ? 'vertical' : type === 'vertical' ? 'horizontal' : region;
            }
            obj['panRegion'] = panRegion;
        };
        Transform.prototype.rotate = function (degree, obj) {
            var parent = this.parent;
            var isRotate = false;
            if (!parent.disabled && parent.isImageLoaded && (degree % 90 === 0)) {
                this.rotateImage(degree);
            }
            obj['isRotate'] = isRotate;
        };
        Transform.prototype.flip = function (direction) {
            var parent = this.parent;
            if (!parent.disabled && parent.isImageLoaded) {
                this.flipImage(direction);
            }
        };
        Transform.prototype.update = function () {
            var parent = this.parent;
            var toolbarHeight = 0;
            var isActiveObj = false;
            var freehandObj = { bool: false };
            var straightenObj = { bool: parent.isStraightening };
            var cxtTbarHeight = 0;
            var ctToolbar = parent.element.querySelector('#' + parent.element.id + '_contextualToolbar');
            var ctWrapper = parent.element.querySelector('.e-contextual-toolbar-wrapper');
            var hdWrapper = parent.element.querySelector('#' + parent.element.id + '_headWrapper');
            if (parent.isImageLoaded) {
                var isCropSelection = false;
                var splitWords = void 0;
                Iif (ej2_base_1.Browser.isDevice) {
                    if (parent.activeObj.shape) {
                        splitWords = parent.activeObj.shape.split('-');
                    }
                    if (parent.currObjType.isCustomCrop) {
                        isCropSelection = true;
                    }
                    else if (splitWords && splitWords[0] === 'crop') {
                        isCropSelection = true;
                    }
                }
                var frameObj = { bool: null };
                parent.notify('toolbar', { prop: 'getFrameToolbar', onPropertyChange: false, value: { obj: frameObj } });
                if (!straightenObj['bool'] && ((ctToolbar && !ctToolbar.parentElement.classList.contains('e-hide')) ||
                    (hdWrapper && !hdWrapper.parentElement.classList.contains('e-hide')))) {
                    ctWrapper.classList.add('e-hide');
                    Eif (!isCropSelection) {
                        parent.okBtn(null, true);
                    }
                    parent.notify('toolbar', { prop: 'refresh-main-toolbar', onPropertyChange: false });
                    parent.notify('toolbar', { prop: 'destroy-qa-toolbar', onPropertyChange: false });
                }
                parent.notify('selection', { prop: 'getFreehandDrawEditing', onPropertyChange: false, value: { obj: freehandObj } });
                if (freehandObj['bool']) {
                    parent.notify('toolbar', { prop: 'destroy-qa-toolbar', onPropertyChange: false });
                }
                var actPoint = ej2_base_1.extend({}, parent.activeObj.activePoint, {}, true);
                if (parent.activeObj.shape && (actPoint.width !== 0 || actPoint.height !== 0)) {
                    isActiveObj = true;
                    if (parent.textArea.style.display === 'block' || parent.textArea.style.display === 'inline-block') {
                        parent.notify('shape', { prop: 'redrawActObj', onPropertyChange: false,
                            value: { x: null, y: null, isMouseDown: null } });
                        parent.notify('toolbar', { prop: 'destroy-qa-toolbar', onPropertyChange: false });
                    }
                    else {
                        parent.notify('shape', { prop: 'updImgRatioForActObj', onPropertyChange: false });
                        parent.objColl.push(parent.activeObj);
                    }
                    parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
                }
            }
            parent.updateDropInfoContent(parent.element.querySelector('.e-ie-drop-info'));
            var tempFilter = this.lowerContext.filter;
            var canvasWrapper = parent.element.querySelector('#' + parent.element.id + '_canvasWrapper');
            Eif (canvasWrapper) {
                canvasWrapper.style.width = parent.element.offsetWidth - 2 + 'px';
            }
            parent.lowerCanvas.width = parent.upperCanvas.width = parent.maskCanvas.width = parent.element.offsetWidth - 2;
            if (parent.toolbarTemplate) {
                toolbarHeight = parent.element.querySelector('#' + parent.element.id + '_toolbarArea').clientHeight;
            }
            else if (parent.element.querySelector('#' + parent.element.id + '_toolbar')) {
                toolbarHeight = parent.element.querySelector('#' + parent.element.id + '_toolbar').clientHeight;
                if (toolbarHeight === 0 && parent.toolbar && parent.toolbar.length > 0 && parent.toolbar.indexOf('Open') === -1) {
                    var obj = { toolbarHeight: 0 };
                    parent.notify('toolbar', { prop: 'getToolbarHeight', value: { obj: obj } });
                    toolbarHeight = obj['toolbarHeight'];
                }
            }
            var ctxTbarArea = parent.element.querySelector('#' + parent.element.id + '_contextualToolbarArea');
            Iif (ej2_base_1.Browser.isDevice && straightenObj['bool'] && ctxTbarArea) {
                cxtTbarHeight = ctxTbarArea.clientHeight;
            }
            parent.notify('toolbar', { prop: 'setToolbarHeight', value: { height: toolbarHeight } });
            Iif (ej2_base_1.Browser.isDevice) {
                if (canvasWrapper) {
                    canvasWrapper.style.height = parent.element.offsetHeight - ((2 * toolbarHeight) + cxtTbarHeight) - 4 + 'px';
                }
            }
            else {
                Eif (canvasWrapper) {
                    canvasWrapper.style.height = parent.element.offsetHeight - toolbarHeight - 2 + 'px';
                }
            }
            parent.lowerCanvas.height = parent.upperCanvas.height = parseFloat(canvasWrapper.style.height);
            this.lowerContext.filter =
                'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
                    'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
            parent.notify('filter', { prop: 'setAdjustmentValue', onPropertyChange: false, value: { adjustmentValue: this.lowerContext.filter } });
            parent.canvasFilter = this.lowerContext.filter;
            parent.initialAdjustmentValue = this.lowerContext.filter;
            parent.clearContext(this.lowerContext);
            parent.clearContext(this.upperContext);
            if (parent.isImageLoaded) {
                parent.notify('shape', { prop: 'applyActObj', onPropertyChange: false, value: { isMouseDown: null } });
                parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
                this.lowerContext.filter = tempFilter;
                parent.initialAdjustmentValue = tempFilter;
                parent.canvasFilter = this.lowerContext.filter;
                Eif (parent.isImageLoaded) {
                    ej2_popups_1.showSpinner(parent.element);
                    parent.element.style.opacity = '0.5';
                }
                this.lowerContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
                this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
                Eif (canvasWrapper) {
                    canvasWrapper.style.width = parent.element.offsetWidth - 2 + 'px';
                    canvasWrapper.style.height = parent.element.offsetHeight + 'px';
                    var obj_1 = { toolbarHeight: 0 };
                    parent.notify('toolbar', { prop: 'getToolbarHeight', value: { obj: obj_1 } });
                    Iif (ej2_base_1.Browser.isDevice) {
                        canvasWrapper.style.height = (parseFloat(canvasWrapper.style.height) - (2 * obj_1['toolbarHeight']) - cxtTbarHeight) - 4 + 'px';
                    }
                    else {
                        canvasWrapper.style.height = (parseFloat(canvasWrapper.style.height) - obj_1['toolbarHeight']) - 2 + 'px';
                    }
                }
                parent.lowerCanvas.width = parent.upperCanvas.width = parent.maskCanvas.width =
                    parseFloat(canvasWrapper.style.width);
                parent.lowerCanvas.height = parent.upperCanvas.height = parent.maskCanvas.height =
                    parseFloat(canvasWrapper.style.height);
                this.lowerContext.filter = tempFilter;
                this.lowerContext.imageSmoothingQuality = parent.imageSmoothingEnabled ? 'high' : 'low';
                var obj = { width: 0, height: 0 };
                this.calcMaxDimension(parent.img.srcWidth, parent.img.srcHeight, obj);
                var maxDimension = obj;
                if (straightenObj['bool'] && parent.transform.cropZoomFactor !== 0) {
                    maxDimension.width += (maxDimension.width * parent.transform.cropZoomFactor);
                    maxDimension.height += (maxDimension.height * parent.transform.cropZoomFactor);
                }
                else if (parent.transform.defaultZoomFactor > 0) {
                    maxDimension.width += (maxDimension.width * parent.transform.defaultZoomFactor);
                    maxDimension.height += (maxDimension.height * parent.transform.defaultZoomFactor);
                }
                parent.img.destLeft = (parent.lowerCanvas.clientWidth - maxDimension.width) / 2;
                parent.img.destTop = (parent.lowerCanvas.clientHeight - maxDimension.height) / 2;
                if (parent.transform.degree === 0 && parent.transform.currFlipState === '') {
                    if (parent.transform.defaultZoomFactor > 0) {
                        parent.img.destLeft += parent.panPoint.totalPannedPoint.x;
                        parent.img.destTop += parent.panPoint.totalPannedPoint.y;
                    }
                    parent.notify('draw', { prop: 'draw-image-to-canvas', value: { dimension: maxDimension } });
                }
                else {
                    parent.notify('draw', { prop: 'draw-image-to-canvas', value: { dimension: maxDimension } });
                    parent.notify('draw', { prop: 'updateCurrTransState', onPropertyChange: false,
                        value: { type: 'initial', isPreventDestination: null, isRotatePan: null } });
                    var temp = this.lowerContext.filter;
                    parent.notify('draw', { prop: 'drawImage', onPropertyChange: false });
                    this.lowerContext.filter = temp;
                    parent.notify('draw', { prop: 'updateCurrTransState', onPropertyChange: false,
                        value: { type: 'reverse', isPreventDestination: null, isRotatePan: null } });
                }
                parent.notify('shape', { prop: 'drawAnnotations', onPropertyChange: false,
                    value: { ctx: this.lowerContext, shape: 'zoom', pen: 'zoom', isPreventApply: null } });
                parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.lowerContext } });
                parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.upperContext } });
                Iif (parent.isCircleCrop) {
                    parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
                        value: { context: this.lowerContext, isSave: null, isFlip: null } });
                }
                ej2_popups_1.hideSpinner(parent.element);
                parent.element.style.opacity = '1';
                var obj1 = { defToolbarItems: null };
                parent.notify('toolbar', { prop: 'getDefToolbarItems', value: { obj: obj1 } });
                Eif (obj1['defToolbarItems'] && obj1['defToolbarItems'].length > 0 && document.getElementById(parent.element.id + '_toolbar')) {
                    var toolbar_1 = ej2_base_1.getComponent(parent.element.id + '_toolbar', 'toolbar');
                    Eif (toolbar_1) {
                        toolbar_1.refreshOverflow();
                    }
                    if (ctWrapper && !straightenObj['bool']) {
                        ctWrapper.classList.add('e-hide');
                    }
                }
                parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
                this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
                if (isActiveObj) {
                    var activeObj = ej2_base_1.extend({}, parent.objColl[parent.objColl.length - 1], null, true);
                    parent.objColl.pop();
                    Eif (activeObj.activePoint.width !== 0 && activeObj.activePoint.height !== 0) {
                        this.lowerContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
                        parent.notify('draw', { prop: 'render-image', value: { isMouseWheel: null } });
                        parent.objColl.push(activeObj);
                        parent.notify('shape', { prop: 'drawAnnotations', onPropertyChange: false,
                            value: { ctx: this.lowerContext, shape: 'zoom', pen: 'zoom', isPreventApply: null } });
                        activeObj = ej2_base_1.extend({}, parent.objColl[parent.objColl.length - 1], null, true);
                        parent.objColl.pop();
                        this.lowerContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
                        parent.notify('draw', { prop: 'render-image', value: { isMouseWheel: null } });
                        parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: activeObj } });
                        if (straightenObj['bool']) {
                            parent.notify('draw', { prop: 'setStraightenActObj', value: { activeObj: activeObj } });
                        }
                        if (parent.activeObj.shape === 'rectangle' || parent.activeObj.shape === 'ellipse' || parent.activeObj.shape === 'text' ||
                            parent.activeObj.shape === 'line' || parent.activeObj.shape === 'arrow' || parent.activeObj.shape === 'path' ||
                            parent.activeObj.shape === 'image') {
                            parent.notify('toolbar', { prop: 'renderQAT', onPropertyChange: false, value: { isPenEdit: null } });
                        }
                    }
                }
                if (freehandObj['bool']) {
                    parent.notify('toolbar', { prop: 'renderQAT', onPropertyChange: false, value: { isPenEdit: true } });
                }
                if (parent.isResize) {
                    parent.aspectWidth = Math.ceil(parent.img.destWidth);
                    parent.aspectHeight = Math.ceil(parent.img.destHeight);
                    parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'resize',
                            isApplyBtn: false, isCropping: false } });
                    parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'resize',
                            isApplyBtn: false, isCropping: false } });
                }
                if ((parent.transform.degree !== 0 || parent.transform.currFlipState !== '') && parent.transform.defaultZoomFactor > 0) {
                    var totalPannedPoint = ej2_base_1.extend({}, parent.panPoint.totalPannedPoint, null, true);
                    var totalPannedInternalPoint = ej2_base_1.extend({}, parent.panPoint.totalPannedInternalPoint, null, true);
                    var totalPannedClientPoint = ej2_base_1.extend({}, parent.panPoint.totalPannedClientPoint, null, true);
                    this.zoomAction(.1);
                    this.zoomAction(-.1);
                    if (parent.transform.degree === 0) {
                        parent.img.destLeft += totalPannedPoint.x;
                        parent.img.destTop += totalPannedPoint.y;
                        parent.panPoint.totalPannedPoint = totalPannedPoint;
                        parent.notify('draw', { prop: 'updateFlipPan', value: { tempSelectionObj: null } });
                    }
                    else {
                        parent.panPoint.totalPannedInternalPoint = totalPannedInternalPoint;
                        parent.panPoint.totalPannedClientPoint = totalPannedClientPoint;
                        parent.panPoint.currentPannedPoint = { x: 0, y: 0 };
                        parent.isCropTab = true;
                        this.rotatePan();
                        parent.isCropTab = false;
                    }
                }
                else if (parent.transform.degree !== 0 && parent.transform.cropZoomFactor > 0) {
                    parent.transform.zoomFactor = 0;
                    parent.transform.cropZoomFactor = null;
                    parent.notify('toolbar', { prop: 'enable-disable-btns', onPropertyChange: false });
                }
            }
        };
        Transform.prototype.calcMaxDimension = function (width, height, obj, isImgShape) {
            var object = { toolbarHeight: 0 };
            var parent = this.parent;
            parent.notify('toolbar', { prop: 'getToolbarHeight', value: { obj: object } });
            var newWidth = parent.imageSettings.width ? parent.imageSettings.width : parent.element.clientWidth;
            var newHeight = parent.imageSettings.height ? parent.imageSettings.height : parent.element.clientHeight - (object['toolbarHeight']);
            var canvasMaxWidth = isImgShape ? parent.element.clientWidth / 3 : newWidth;
            var canvasMaxHeight = isImgShape ? (parent.element.clientHeight - object['toolbarHeight']) / 3 : newHeight;
            canvasMaxHeight = ej2_base_1.Browser.isDevice ? canvasMaxHeight - (object['toolbarHeight']) : canvasMaxHeight;
            Iif (ej2_base_1.Browser.isDevice && parent.isStraightening) {
                var cxtTbar = parent.element.querySelector('#' + parent.element.id + '_contextualToolbarArea');
                canvasMaxHeight -= cxtTbar ? cxtTbar.clientHeight : 0;
            }
            Iif (!isImgShape && parent.element.clientHeight === 0) {
                canvasMaxHeight = 0;
            }
            var isImageSettings = parent.imageSettings.width && parent.imageSettings.height ? true : false;
            if (ej2_base_1.isNullOrUndefined(isImgShape) && !(isImageSettings)) {
                Eif (canvasMaxWidth > 30) {
                    canvasMaxWidth -= 30;
                }
                if (canvasMaxHeight > 30) {
                    canvasMaxHeight -= 30;
                }
            }
            var widthScale = canvasMaxWidth / width;
            var heightScale = canvasMaxHeight / height;
            var cssMaxWidth = Math.min(width, canvasMaxWidth);
            var cssMaxHeight = Math.min(height, canvasMaxHeight);
            if (widthScale < 1 && widthScale < heightScale) {
                cssMaxWidth = width * widthScale;
                cssMaxHeight = height * widthScale;
            }
            else if (heightScale < 1 && heightScale < widthScale) {
                cssMaxWidth = width * heightScale;
                cssMaxHeight = height * heightScale;
            }
            if (ej2_base_1.isNullOrUndefined(isImgShape)) {
                var cropObj = { bool: null };
                parent.notify('crop', { prop: 'getPreventScaling', onPropertyChange: false,
                    value: { obj: cropObj } });
                Iif (cropObj['bool'] && parent.cropObj.activeObj.activePoint &&
                    parent.cropObj.activeObj.activePoint.width !== 0 && parent.cropObj.activeObj.activePoint.height !== 0) {
                    cssMaxWidth = parent.cropObj.activeObj.activePoint.width;
                    cssMaxHeight = parent.cropObj.activeObj.activePoint.height;
                }
            }
            if (obj) {
                obj['width'] = cssMaxWidth;
                obj['height'] = cssMaxHeight;
            }
            return { width: cssMaxWidth, height: cssMaxHeight };
        };
        Transform.prototype.updatePanPoints = function (x, y) {
            var parent = this.parent;
            var tempActObj = ej2_base_1.extend({}, parent.activeObj, {}, true);
            var tempDestLeft = parent.img.destLeft;
            var tempDestTop = parent.img.destTop;
            Iif (ej2_base_1.isNullOrUndefined(this.tempPanMove)) {
                this.tempPanMove = { x: this.panMove.x, y: this.panMove.y };
            }
            var xDiff = this.panMove.x - this.tempPanMove.x;
            var yDiff = this.panMove.y - this.tempPanMove.y;
            if (x || y) {
                xDiff = x;
                yDiff = y;
            }
            parent.img.destLeft += xDiff;
            parent.img.destTop += yDiff;
            this.limitPan();
            var obj = { bool: null };
            var object = { isIntersect: null };
            parent.notify('draw', { prop: 'updateImgCanvasPoints', onPropertyChange: false });
            parent.notify('draw', { prop: 'isLinesIntersect', onPropertyChange: false, value: { obj: object } });
            parent.notify('draw', { prop: 'isSelOutsideImg', onPropertyChange: false, value: { obj: obj } });
            var count = 0;
            while (parent.transform.straighten !== 0 && (object['isIntersect'] || obj['bool'])) {
                count++;
                parent.img.destLeft = tempDestLeft;
                parent.img.destTop = tempDestTop;
                if (xDiff !== 0 && xDiff > 0) {
                    xDiff -= 1;
                }
                else if (xDiff !== 0 && xDiff < 0) {
                    xDiff += 1;
                }
                if (yDiff !== 0 && yDiff > 0) {
                    yDiff -= 1;
                }
                else if (yDiff !== 0 && yDiff < 0) {
                    yDiff += 1;
                }
                if ((xDiff === 0 && yDiff === 0) || count === 200) {
                    break;
                }
                parent.img.destLeft += xDiff;
                parent.img.destTop += yDiff;
                this.limitPan();
                parent.notify('draw', { prop: 'updateImgCanvasPoints', onPropertyChange: false });
                parent.notify('draw', { prop: 'isLinesIntersect', onPropertyChange: false, value: { obj: object } });
                parent.notify('draw', { prop: 'isSelOutsideImg', onPropertyChange: false, value: { obj: obj } });
            }
            parent.activeObj = tempActObj;
            return { x: parent.img.destLeft - tempDestLeft, y: parent.img.destTop - tempDestTop };
        };
        Transform.prototype.resizeImage = function (width, height) {
            var parent = this.parent;
            var temp = true;
            var temp1 = true;
            parent.allowDownScale = false;
            parent.img.srcLeft = 0;
            parent.img.srcTop = 0;
            parent.isAspectRatio = true;
            var minimum = [];
            parent.img.srcWidth = parent.baseImgCanvas.width;
            parent.img.srcHeight = parent.baseImgCanvas.height;
            Eif (parent.resizeSrc && parent.resizeSrc.width !== 0 && parent.resizeSrc.height !== 0) {
                parent.img.srcLeft = parent.resizeSrc.startX;
                parent.img.srcTop = parent.resizeSrc.startY;
                parent.img.srcWidth = parent.resizeSrc.width;
                parent.img.srcHeight = parent.resizeSrc.height;
            }
            while ((width < parent.img.destWidth || height < parent.img.destHeight) && temp1) {
                this.zoomAction(-.1, null, true, true);
                if (width > parent.img.destWidth || height > parent.img.destHeight) {
                    while (width > parent.img.destWidth || height > parent.img.destHeight) {
                        this.zoomAction(0.0125, null, true, true);
                        temp1 = false;
                        minimum.push(parent.img.destWidth);
                    }
                }
            }
            while ((width > parent.img.destWidth || height > parent.img.destHeight) && temp1 && temp) {
                this.zoomAction(.1, null, true, true);
                if (width < parent.img.destWidth || height < parent.img.destHeight) {
                    while (width < parent.img.destWidth) {
                        this.zoomAction(-.0125, null, true, true);
                        temp = false;
                        minimum.push(parent.img.destWidth);
                    }
                }
            }
            var nearestNumber = minimum[0];
            var smallestDifference = Math.abs(parent.img.destWidth - nearestNumber);
            for (var _i = 0, minimum_1 = minimum; _i < minimum_1.length; _i++) {
                var num = minimum_1[_i];
                var difference = Math.abs(width - num);
                if (difference < smallestDifference) {
                    nearestNumber = num;
                    smallestDifference = difference;
                }
            }
            if (nearestNumber < width && temp) {
                this.zoomAction(-.0125, null, true, true);
                temp = false;
            }
            Iif (nearestNumber > width && !temp) {
                this.zoomAction(.0125, null, true, true);
                temp = false;
            }
            this.zoomAction(.0125, null, true);
            parent.allowDownScale = true;
            this.zoomAction(-.0125, null, true);
            var prevCropObj = ej2_base_1.extend({}, parent.cropObj, {}, true);
            var prevObj = ej2_base_1.extend({}, this.prevResizeCurrObj, {}, true);
            parent.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false, value: { operation: 'resize',
                    previousObj: prevObj, previousObjColl: prevObj.objColl, previousPointColl: prevObj.pointColl,
                    previousSelPointColl: prevObj.selPointColl, previousCropObj: prevCropObj, previousText: null, currentText: null,
                    previousFilter: null, isCircleCrop: parent.isCircleCrop } });
            parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
        };
        Transform.prototype.resizeCrop = function (width, height) {
            var parent = this.parent;
            var temp = true;
            var obj1 = { prevObj: parent.prevObj };
            parent.cropObj = ej2_base_1.extend({}, parent.prevCropObj, {}, true);
            parent.allowDownScale = false;
            parent.notify('toolbar', { prop: 'getPrevObj', onPropertyChange: false, value: { obj: obj1 } });
            var activeObj = ej2_base_1.extend({}, obj1['prevObj']['activeObj'], {}, true);
            obj1['prevObj']['activeObj'] = ej2_base_1.extend({}, parent.activeObj, {}, true);
            parent.notify('draw', { prop: 'setCurrentObj', onPropertyChange: false, value: { obj: obj1['prevObj'] } });
            parent.objColl = ej2_base_1.extend([], obj1['prevObj']['objColl'], [], true);
            parent.pointColl = ej2_base_1.extend([], obj1['prevObj']['pointColl'], [], true);
            parent.transform.straighten = 0;
            parent.notify('shape', { prop: 'drawAnnotations', onPropertyChange: false,
                value: { ctx: this.lowerContext, shape: 'zoom', pen: 'zoom', isPreventApply: null } });
            Eif (parent.transform.straighten === 0 && !this.isPreventSelect) {
                parent.notify('freehand-draw', { prop: 'updateFHDColl', onPropertyChange: false });
            }
            var tempwidth = width;
            var tempheight = height;
            var tempZoom = false;
            if (height >= width && height <= Math.ceil(parent.img.destHeight)) {
                while ((height <= Math.ceil(parent.img.destHeight)) && temp) {
                    this.zoomAction(-.1, null, true, true);
                    if (width > parent.img.destWidth || height > parent.img.destHeight) {
                        while (width > parent.img.destWidth || height > parent.img.destHeight) {
                            this.zoomAction(.0125, null, true, true);
                            temp = false;
                        }
                    }
                }
            }
            else if (height <= width && width < parent.img.destWidth) {
                while ((width < parent.img.destWidth) && temp) {
                    this.zoomAction(-.1, null, true, true);
                    if (width > parent.img.destWidth || height > parent.img.destHeight) {
                        while (width > parent.img.destWidth || height > parent.img.destHeight) {
                            this.zoomAction(.0125, null, true, true);
                            temp = false;
                        }
                    }
                }
            }
            else if (height >= width && height >= parent.img.destHeight) {
                while ((height >= parent.img.destHeight) && temp) {
                    this.zoomAction(.1, null, true, true);
                }
            }
            else Eif (width >= height && width >= parent.img.destWidth) {
                while ((width >= parent.img.destWidth) && temp) {
                    this.zoomAction(.1, null, true, true);
                }
                Eif (width < parent.img.destWidth && height < parent.img.destHeight) {
                    while (width < parent.img.destWidth && height < parent.img.destHeight) {
                        this.zoomAction(-.0125, null, true, true);
                        temp = false;
                    }
                    this.zoomAction(.0125, null, true, true);
                }
            }
            else if (height > parent.img.destHeight && width > parent.img.destWidth) {
                while ((height > parent.img.destHeight) && (width > parent.img.destWidth) && temp) {
                    this.zoomAction(.1, null, true, true);
                }
                if (width < parent.img.destWidth && height < parent.img.destHeight) {
                    while (width < parent.img.destWidth && height < parent.img.destHeight) {
                        this.zoomAction(-.0125, null, true, true);
                        temp = false;
                    }
                    this.zoomAction(.0125, null, true, true);
                }
            }
            Iif (parent.isPublicMethod && parent.aspectWidth === width && parent.aspectHeight === height) {
                return;
            }
            this.resizeImg(activeObj, width, height);
            width = tempwidth;
            height = tempheight;
            Eif ((height !== parent.img.destHeight || width !== parent.img.destWidth)) {
                while ((height > parent.img.destHeight || width > parent.img.destWidth)) {
                    this.zoomAction(.0125, null, true, true);
                    tempZoom = true;
                }
                if (tempZoom) {
                    this.zoomAction(-.0125, null, true, true);
                    tempZoom = false;
                }
            }
            Eif ((height !== parent.img.destHeight || width !== parent.img.destWidth)) {
                while ((height < parent.img.destHeight || width < parent.img.destWidth)) {
                    this.zoomAction(-.0125, null, true, true);
                    tempZoom = true;
                }
                if (tempZoom) {
                    this.zoomAction(-.0125, null, true, true);
                    tempZoom = false;
                }
            }
            obj1['prevObj']['activeObj'] = ej2_base_1.extend({}, activeObj, {}, true);
            this.zoomAction(.0125, null, true);
            parent.allowDownScale = this.preventDownScale ? false : true;
            parent.isCropTab = false;
            this.zoomAction(-.0125, null, true);
            parent.aspectWidth = width;
            parent.aspectHeight = height;
        };
        Transform.prototype.resizeImg = function (activeObj, width, height) {
            var parent = this.parent;
            var widthRatio = width / parent.img.destWidth;
            var heightRatio = height / parent.img.destHeight;
            if (activeObj.shape) {
                parent.currSelectionPoint = activeObj;
                parent.notify('crop', { prop: 'setInitCrop', onPropertyChange: false, value: { bool: true } });
            }
            else Eif (parent.img.srcWidth === parent.baseImgCanvas.width && parent.img.srcHeight === parent.baseImgCanvas.height) {
                parent.currSelectionPoint = null;
                parent.notify('draw', { prop: 'select', onPropertyChange: false,
                    value: { type: 'custom', startX: null, startY: null, width: null, height: null } });
            }
            if (ej2_base_1.isNullOrUndefined(parent.currSelectionPoint)) {
                Eif (!parent.shapeColl.some(function (item) { return item.rotatedAngle && item.rotatedAngle !== 0; })) {
                    parent.notify('draw', { prop: 'select', onPropertyChange: false,
                        value: { type: 'custom', startX: parent.img.destLeft, startY: parent.img.destTop,
                            width: parent.img.destWidth, height: parent.img.destHeight } });
                }
            }
            else {
                parent.notify('draw', { prop: 'select', onPropertyChange: false,
                    value: { type: 'custom', startX: null, startY: null, width: null, height: null } });
            }
            width = parent.activeObj.activePoint.width * widthRatio;
            height = parent.activeObj.activePoint.height * heightRatio;
            var sx = (parent.activeObj.activePoint.startX + (parent.activeObj.activePoint.width / 2)) - (width / 2);
            var sy = (parent.activeObj.activePoint.startY + (parent.activeObj.activePoint.height / 2)) - (height / 2);
            var count = 0;
            while (ej2_base_1.Browser.isDevice && count < 500 && (sx < 0 || sy < 0 || (sx + width) > parent.img.destWidth
                || (sy + height) > parent.img.destHeight)) {
                count++;
                width -= 1;
                height -= 1;
                sx = (parent.activeObj.activePoint.startX + (parent.activeObj.activePoint.width / 2)) - (width / 2);
                sy = (parent.activeObj.activePoint.startY + (parent.activeObj.activePoint.height / 2)) - (height / 2);
            }
            parent.transform.defaultZoomFactor = 0;
            parent.notify('draw', { prop: 'setResizeSelect', value: { bool: true } });
            parent.notify('draw', { prop: 'setIsCropSelect', value: { bool: true } });
            parent.notify('draw', { prop: 'select', onPropertyChange: false,
                value: { type: 'custom', startX: sx, startY: sy, width: width, height: height } });
            parent.notify('draw', { prop: 'setResizeSelect', value: { bool: false } });
            if (parent.transform.straighten !== 0) {
                var obj = { isIntersect: null, arr: null };
                parent.notify('draw', { prop: 'updateImgCanvasPoints', onPropertyChange: false });
                parent.notify('draw', { prop: 'isLinesIntersect', onPropertyChange: false, value: { obj: obj } });
                while (obj['arr'][0] || obj['arr'][1] || obj['arr'][2] || obj['arr'][3]) {
                    this.zoomAction(.0125, null, true);
                    parent.notify('draw', { prop: 'updateImgCanvasPoints', onPropertyChange: false });
                    parent.notify('draw', { prop: 'isLinesIntersect', onPropertyChange: false, value: { obj: obj } });
                }
            }
            parent.isCropToolbar = true;
            parent.crop();
            parent.isCropToolbar = false;
        };
        Transform.prototype.updateResize = function () {
            var parent = this.parent;
            parent.prevCropObj = ej2_base_1.extend({}, parent.cropObj, {}, true);
            var currObject = { currObj: {} };
            parent.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: currObject } });
            parent.prevObj = currObject['currObj'];
            if (parent.currSelectionPoint && parent.prevCropObj.activeObj.shape) {
                parent.prevObj.activeObj = ej2_base_1.extend({}, parent.prevCropObj.activeObj, {}, true);
            }
            parent.prevObj.objColl = ej2_base_1.extend([], parent.objColl, [], true);
            parent.prevObj.pointColl = ej2_base_1.extend([], parent.pointColl, [], true);
            parent.prevObj.afterCropActions = ej2_base_1.extend([], parent.afterCropActions, [], true);
            var selPointCollObj = { selPointColl: null };
            parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
                value: { obj: selPointCollObj } });
            parent.prevObj.selPointColl = ej2_base_1.extend([], selPointCollObj['selPointColl'], [], true);
            parent.resizeSrc = { startX: parent.img.srcLeft, startY: parent.img.srcTop, width: parent.img.srcWidth,
                height: parent.img.srcHeight };
        };
        Transform.prototype.resize = function (width, height, isAspectRatio) {
            var parent = this.parent;
            var aspectHeight;
            parent.isResize = true;
            Iif (ej2_base_1.isNullOrUndefined(parent.prevCropObj) && ej2_base_1.isNullOrUndefined(parent.prevObj)) {
                parent.notify('transform', { prop: 'updateResize', value: { bool: false } });
            }
            var aspectIcon = parent.element.querySelector('#' + parent.element.id + '_aspectratio');
            var nonAspectIcon = parent.element.querySelector('#' + parent.element.id + '_nonaspectratio');
            Iif (aspectIcon && nonAspectIcon) {
                parent.notify('toolbar', { prop: 'initResizeToolbar' });
                if (ej2_base_1.Browser.isDevice) {
                    parent.notify('toolbar', { prop: 'init-main-toolbar', value: { isApplyBtn: false, isDevice: true, isOkBtn: true, isResize: true } });
                }
            }
            var aspectRatioHeight = parent.element.querySelector('#' + parent.element.id + '_resizeHeight');
            if (aspectRatioHeight) {
                aspectHeight = aspectRatioHeight.value === '' ? aspectRatioHeight.placeholder : aspectRatioHeight.value;
            }
            else {
                aspectHeight = height + 'px';
            }
            var resizeEventArgs = { cancel: false, previousWidth: Math.ceil(parent.img.destWidth),
                previousHeight: Math.ceil(parent.img.destHeight), width: Math.ceil(width), height: height && height !== 0 ? Math.ceil(height) :
                    (isAspectRatio ? Math.ceil(parseFloat(aspectHeight)) : Math.ceil(parent.img.destHeight)),
                isAspectRatio: isAspectRatio ? isAspectRatio : false };
            parent.trigger('resizing', resizeEventArgs);
            parent.editCompleteArgs = resizeEventArgs;
            Eif (!resizeEventArgs.cancel) {
                this.resizeEventHandler(resizeEventArgs);
            }
            else if (parent.aspectHeight && parent.aspectWidth) {
                parent.aspectHeight = resizeEventArgs.previousHeight;
                parent.aspectWidth = resizeEventArgs.previousWidth;
            }
        };
        Transform.prototype.resizeEventHandler = function (args) {
            var parent = this.parent;
            var isRotate;
            var aspectRatioWidth = parent.element.querySelector('#' + parent.element.id + '_resizeWidth');
            var aspectRatioHeight = parent.element.querySelector('#' + parent.element.id + '_resizeHeight');
            if (args.isAspectRatio) {
                if (this.resizedImgAngle == null || this.resizedImgAngle !== parent.transform.degree) {
                    this.resizedImgAngle = parent.transform.degree;
                    isRotate = true;
                }
                if (isRotate) {
                    parent.notify('transform', { prop: 'resizeImage', value: { width: args.width, height: 0 } });
                    var originalWidth = parent.img.destWidth;
                    var originalHeight = parent.img.destHeight;
                    var aspectRatioWidthValue = void 0;
                    if (aspectRatioHeight) {
                        aspectRatioWidthValue = parseFloat(aspectRatioWidth.value === '' ? aspectRatioWidth.placeholder : aspectRatioWidth.value);
                        var value = aspectRatioWidthValue / (originalWidth / originalHeight);
                        var height = value % 1 >= 0.5 || value % 1 <= -0.5 ? Math.round(value) : (value < 0) ? Math.ceil(value) : Math.floor(value);
                        ej2_base_1.getComponent(aspectRatioHeight, 'numerictextbox').value = height;
                        aspectRatioHeight.value = height.toString() + ' px';
                        parent.aspectHeight = height;
                        if (aspectRatioWidth && aspectRatioWidth.value === '') {
                            var aspectRatioHeightValue = parseFloat(aspectRatioHeight.value === '' ? aspectRatioHeight.placeholder :
                                aspectRatioHeight.value);
                            value = aspectRatioHeightValue / (originalHeight / originalWidth);
                            var width = value % 1 >= 0.5 || value % 1 <= -0.5 ? Math.round(value) : (value < 0) ? Math.ceil(value) : Math.floor(value);
                            ej2_base_1.getComponent(aspectRatioWidth, 'numerictextbox').value = width;
                            aspectRatioWidth.value = width.toString() + ' px';
                            parent.aspectWidth = width;
                        }
                    }
                }
                else {
                    parent.notify('transform', { prop: 'resizeImage', value: { width: args.width, height: null } });
                }
            }
            else {
                Iif (this.resizedImgAngle !== null && this.resizedImgAngle !== parent.transform.degree) {
                    this.resizedImgAngle = parent.transform.degree;
                    isRotate = true;
                }
                Iif (isRotate) {
                    parent.notify('transform', { prop: 'setPreventDownScale', value: { bool: true } });
                    parent.notify('transform', { prop: 'resizeCrop', value: { width: args.width, height: args.height } });
                    parent.notify('undo-redo', { prop: 'setPreventUR', value: { bool: true } });
                    parent.okBtn(null, true);
                    parent.notify('undo-redo', { prop: 'setPreventUR', value: { bool: false } });
                    parent.resizeSrc = { startX: parent.img.srcLeft, startY: parent.img.srcTop, width: parent.img.srcWidth,
                        height: parent.img.srcHeight };
                    parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'resize',
                            isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
                    parent.notify('transform', { prop: 'setPreventDownScale', value: { bool: false } });
                    parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'resize',
                            isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
                }
                else {
                    parent.notify('transform', { prop: 'resizeCrop', value: { width: args.width, height: args.height } });
                }
            }
            this.resizedImgAngle = parent.transform.degree;
        };
        Transform.prototype.straightenImage = function (degree) {
            var parent = this.parent;
            var isSelection = parent.activeObj.shape && parent.activeObj.shape.indexOf('crop-') > -1;
            Iif (parent.toolbar && parent.toolbar.length === 0) {
                parent.notify('draw', { prop: 'select', onPropertyChange: false,
                    value: { type: 'custom', startX: null, startY: null, width: null, height: null } });
            }
            parent.notify('toolbar', { prop: 'performCropTransformClick', value: { shape: null } });
            parent.setStraighten(degree);
            Eif (!isSelection) {
                parent.okBtn();
            }
        };
        return Transform;
    }());
    exports.Transform = Transform;
});